Skip to content

Commit

Permalink
Merge pull request #620 from qulacs/619-ignore-stub
Browse files Browse the repository at this point in the history
ignore stub
  • Loading branch information
KowerKoint committed Mar 21, 2024
2 parents 98a2751 + 706dd03 commit 62209fd
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 2,965 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ jobs:
- name: Install qulacs Python module
run: pip install .[ci]

# - name: Test if stub is working
# run: |
# python python/stub-test/generate_mypy_tester.py qulacs
# mypy python/stub-test/names_qulacs.py

- name: Test in macOS
run: |
cd ./build
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/ci_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,6 @@ jobs:
- name: Install qulacs Python module
run: pip install .[ci]

- name: Check stubs
run: |
./script/update_stubs.sh
diff=$(git diff)
echo -n "$diff"
# Without `-n`, `echo -n "$diff" | wc -l` is 1 even if `"$diff" is empty.`
test $(echo -n "$diff" | wc -l) -eq 0
- name: Test if stub is working
run: |
python python/stub-test/generate_mypy_tester.py qulacs
mypy python/stub-test/names_qulacs.py
- name: Test in Ubuntu
run: |
cd ./build
Expand Down Expand Up @@ -294,19 +281,6 @@ jobs:
- name: Install MPI Python module
run: pip install mpi4py

- name: Check stubs
run: |
./script/update_stubs.sh
diff=$(git diff)
echo -n "$diff"
# Without `-n`, `echo -n "$diff" | wc -l` is 1 even if `"$diff" is empty.`
test $(echo -n "$diff" | wc -l) -eq 0
- name: Test if stub is working
run: |
python python/stub-test/generate_mypy_tester.py qulacs
mypy python/stub-test/names_qulacs.py
- name: Test in Ubuntu
run: |
cd ./build
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ jobs:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
run: pip install .[ci]

- name: Test if stub is working
run: |
python python/stub-test/generate_mypy_tester.py qulacs
mypy python/stub-test/names_qulacs.py
- name: Test in Windows
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
Expand Down
55 changes: 46 additions & 9 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ jobs:
fail-fast: false
matrix:
os-arch: ["manylinux_x86_64", "win_amd64", "macosx_x86_64", "macosx_arm64"]
python-version: ["3.10"]
cibw-python: ["cp37", "cp38", "cp39", "cp310","cp311"]
exclude:
# cibuildwheel does not support Python 3.7 on macOS arm64.
- cibw-python: "cp37"
os-arch: "macosx_arm64"
cibw-python: ["cp38", "cp39", "cp310", "cp311", "cp312"]
# Documentation for `include`: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
# `include` is processed after `exclude`.
include:
- os-arch: "manylinux_x86_64"
os: "ubuntu-20.04"
Expand All @@ -41,6 +35,17 @@ jobs:
os: "macos-12"
- os-arch: "macosx_arm64"
os: "macos-12"
- cibw-python: "cp38"
python-version: "3.8"
- cibw-python: "cp39"
python-version: "3.9"
- cibw-python: "cp310"
python-version: "3.10"
- cibw-python: "cp311"
python-version: "3.11"
- cibw-python: "cp312"
python-version: "3.12"

runs-on: ${{ matrix.os }}
env:
CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.os-arch }}
Expand All @@ -61,13 +66,38 @@ jobs:
- name: Install Python dependencies
run: python -m pip install cibuildwheel twine

- name: Install boost if ubuntu
if: ${{ contains(matrix.os, 'ubuntu') }}
run: sudo apt update && sudo apt install libboost-dev

- name: Install boost if macos
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew upgrade
brew install boost
brew link boost
- name: Install boost if windows
if: ${{ contains(matrix.os, 'windows') }}
uses: MarkusJx/install-boost@v2.4.0
id: install-boost
with:
boost_version: 1.77.0

- name: Temporary install qulacs to generate stub if ubuntu or macos
if: ${{ contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') }}
run: python -m pip install .[ci]

- name: Temporary install qulacs to generate stub if windows
if: ${{ contains(matrix.os, 'windows') }}
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
CIBW_BUILD: ""
run: python -m pip install .[ci]

- name: Generate stub
run: ./script/update_stubs.sh

- name: Run cibuildwheel for Windows
if: ${{ contains(matrix.os, 'windows') }}
run: python -m cibuildwheel --output-dir wheels
Expand Down Expand Up @@ -98,8 +128,6 @@ jobs:
os: ["ubuntu-20.04"]
runs-on: ${{ matrix.os }}
env:
CXX_COMPILER: "g++-12"
C_COMPILER: "gcc-12"
PYTHON: ${{ matrix.python-version }}
COVERAGE: "ON"
TWINE_USERNAME: "__token__"
Expand All @@ -115,9 +143,18 @@ jobs:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install boost
run: sudo apt update && sudo apt install libboost-dev

- name: Install Python dependencies
run: python -m pip install twine build

- name: Temporary install qulacs to generate stub
run: python -m pip install .[ci]

- name: Generate stub
run: ./script/update_stubs.sh

- name: create sdist
run: python -m build --sdist

Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ dkms.conf

# End of https://www.gitignore.io/api/python,macos

# ignore stub files generated by https://github.com/Qulacs-Osaka/DevOps-OsakaUniv
/typings/
# ignore stub files
*.pyi
py.typed

!/.vscode/tasks.json

# ignore names_* for stub test
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ Install single-thread Qulacs:
USE_OMP=No pip install .
```

If you install qulacs manually, it does not have type stubs.
To include type stubs into the package, you have to run `script/generate_stubs.sh` after the first install and reinstall.

```
pip install .
script/update_stubs.sh
pip install .
```

The number of threads used in Qulacs installed with default options can be controlled via the environment variable `OMP_NUM_THREADS` or `QULACS_NUM_THREADS`.
While `OMP_NUM_THREADS` affects the parallelization of other libraries, `QULACS_NUM_THREADS` controls only the parallelization of QULACS.
Or, if you want to force only Qulacs to use a single thread, You can install single-thread Qulacs with the above command.
Expand Down

0 comments on commit 62209fd

Please sign in to comment.