Skip to content

Commit 9c6f762

Browse files
authored
Changed openqasm3 from submodule dependency to package dependency (#2)
* Changed openqasm3 from submodule dependence to package dependence * Updated github actions * Copy the OpenQASM grammar. Removed the submodule
1 parent 62d4bdb commit 9c6f762

11 files changed

Lines changed: 1293 additions & 49 deletions

File tree

.github/workflows/tests-ast.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,13 @@ jobs:
4040
- name: Install ANTLR4 Python runtime
4141
run: python -mpip install antlr4-python3-runtime==${{ matrix.antlr-version }}
4242

43-
- name: Generate openqasm3 grammar
44-
working-directory: openqasm/source/grammar
45-
run: java -Xmx500M -jar ../../../antlr-${{ matrix.antlr-version }}-complete.jar -o ../openqasm/openqasm3/antlr -Dlanguage=Python3 -visitor qasm3Lexer.g4 qasm3Parser.g4
46-
4743
- name: Install Python dependencies
48-
working-directory: openqasm/source/openqasm
44+
working-directory: source/openpulse
4945
run: python -mpip install -r requirements.txt -r requirements-dev.txt
5046

51-
- name: Build openqasm3 package
52-
working-directory: openqasm/source/openqasm
53-
run: python -mpip install -e .[all]
54-
5547
- name: Generate openpulse grammar
5648
working-directory: source/grammar
57-
run: java -Xmx500M -jar ../../antlr-${{ matrix.antlr-version }}-complete.jar -lib ../../openqasm/source/grammar -o ../openpulse/openpulse/antlr -Dlanguage=Python3 -visitor openpulseLexer.g4 openpulseParser.g4
49+
run: java -Xmx500M -jar ../../antlr-${{ matrix.antlr-version }}-complete.jar -o ../openpulse/openpulse/antlr -Dlanguage=Python3 -visitor openpulseLexer.g4 openpulseParser.g4
5850

5951
- name: Check openpulse format
6052
run: black --check --diff openpulse tests

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "openqasm"]
2-
path = openqasm
3-
url = https://github.com/openqasm/openqasm.git

README.md

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,20 @@ Specifically, the parser passes the body of `cal` and `defcal` written in `OpenP
55
It reuses the classical types and statements from `openqasm3`.
66
## Developing openpulse
77

8-
### Working with submodule
9-
10-
The `openpulse` package depends on the `openqasm3` package. This repo references the
11-
[OpenQASM](https://github.com/openqasm/openqasm) repo as submodule.
12-
13-
To clone `openpulse`, run:
14-
15-
```
16-
git clone --recurse-submodules https://github.com/openqasm/openpulse-python.git
17-
```
18-
19-
If you forgot `--recurse-submodules` during initial cloning, you can run:
20-
21-
```
22-
git submodule update --init --recursive
23-
```
24-
25-
### Build and install openqasm3
26-
27-
We assume that you have already installed `Antlr4` tools following `openqasm/source/openqasm/README.md`
28-
and set up an Python virtual environment for this project.
29-
30-
You will need to build and install `openqasm3` first. Change to the `openqasm/source/grammar`
31-
directory and run:
32-
33-
```
34-
antlr4 -o ../openqasm/openqasm3/antlr -Dlanguage=Python3 -visitor qasm3Lexer.g4 qasm3Parser.g4
35-
```
36-
37-
Then change to the `openqasm/source/openqasm` directory and run:
8+
To install dependencies, change to `source/openpulse` directory and run:
389

3910
```
40-
python -mpip install -r requirements.txt -r requirements-dev.txt
41-
python -mpip install -e ".[all]"
11+
python -m pip install -r requirements.txt -r requirements-dev.txt
4212
```
4313

44-
### Working with openpulse
14+
To reuse classic statements/types, OpenPulse grammar imports OpenQASM grammar. When we update the
15+
OpenPulse grammar, we also need to copy the latest OpenQASM grammar from
16+
https://github.com/openqasm/openqasm/tree/main/source/grammar into the `source/grammar` directory.
4517

4618
Now build the `openpulse` grammar. Change to the `source/grammar` directory and run:
4719

4820
```
49-
antlr4 -lib ../../openqasm/source/grammar -o ../openpulse/openpulse/antlr -Dlanguage=Python3 -visitor openpulseLexer.g4 openpulseParser.g4
21+
antlr4 -o ../openpulse/openpulse/antlr -Dlanguage=Python3 -visitor openpulseLexer.g4 openpulseParser.g4
5022
```
5123

5224
Finally, you can change to the `source/openpulse` directory and run:

openqasm

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)