Skip to content

Commit a223425

Browse files
authored
Update CI setup (#422)
* Fix compiler flags cleanup routine * Update CHANGELOG * Use clang for linking on Clang CI workflows * Fix compiler_test(...) function in setup.py * Fix CI failure when testing locally * Remove LDSHARED for Clang build * Fix linter warnings in setup.py * Update CHANGELOG * Update more workflow files for local actions * Remove deprecated GitHub action for pre-commit * Update CHANGELOG * Update pre-commit hooks versions * Refrain from updating pylint pre-commit hook for now * Fix issue with running pre-commit on CI * Add cache support for pre-commit on CI * Fix name of caching step for pre-commit on CI * Add Python 3.10 for testing on CI * Add Python 3.10 in package metadata * Fix gen_reqfile command if --include-extras is not provided * Add setup option to avoid -march=native when building ProjectQ * Add support for CIBuildWheel in pyproject.toml * Tweak environment variables used during setup * Avoid Linux Musl in CIBuildWheel config * Update GitHub Workflow for publishing a release
1 parent c26f70a commit a223425

File tree

9 files changed

+161
-49
lines changed

9 files changed

+161
-49
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- 3.7
2121
- 3.8
2222
- 3.9
23+
- '3.10'
2324

2425
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
2526
runs-on: ${{ matrix.runs-on }}
@@ -28,6 +29,7 @@ jobs:
2829
- uses: actions/checkout@v2
2930

3031
- name: Get history and tags for SCM versioning to work
32+
if: ${{ !env.ACT }}
3133
run: |
3234
git fetch --prune --unshallow
3335
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
@@ -125,6 +127,7 @@ jobs:
125127
- uses: actions/checkout@v2
126128

127129
- name: Get history and tags for SCM versioning to work
130+
if: ${{ !env.ACT }}
128131
run: |
129132
git fetch --prune --unshallow
130133
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
@@ -134,6 +137,7 @@ jobs:
134137
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel
135138
python3-numpy python3-scipy python3-matplotlib python3-requests python3-networkx
136139
python3-pytest python3-pytest-cov python3-flaky
140+
libomp-dev
137141
--no-install-recommends
138142
139143
- name: Prepare Python env
@@ -169,6 +173,7 @@ jobs:
169173
- uses: actions/checkout@v2
170174

171175
- name: Get history and tags for SCM versioning to work
176+
if: ${{ !env.ACT }}
172177
run: |
173178
git fetch --prune --unshallow
174179
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
@@ -236,6 +241,7 @@ jobs:
236241
- uses: actions/checkout@v2
237242

238243
- name: Get history and tags for SCM versioning to work
244+
if: ${{ !env.ACT }}
239245
run: |
240246
git fetch --prune --unshallow
241247
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
@@ -285,6 +291,7 @@ jobs:
285291
restore-keys: ${{ runner.os }}-doc-pip-
286292

287293
- name: Get history and tags for SCM versioning to work
294+
if: ${{ !env.ACT }}
288295
run: |
289296
git fetch --prune --unshallow
290297
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
@@ -318,6 +325,7 @@ jobs:
318325
- uses: actions/checkout@v2
319326

320327
- name: Get history and tags for SCM versioning to work
328+
if: ${{ !env.ACT }}
321329
run: |
322330
git fetch --prune --unshallow
323331
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

.github/workflows/format.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,26 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Get history and tags for SCM versioning to work
19+
if: ${{ !env.ACT }}
1920
run: |
2021
git fetch --prune --unshallow
2122
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
2223
- uses: actions/setup-python@v2
23-
- uses: pre-commit/action@v2.0.3
24+
25+
- name: Install pre-commit
26+
run: python3 -m pip install --upgrade pre-commit 'virtualenv!=20.11'
27+
28+
- name: Cache pre-commit hooks
29+
uses: actions/cache@v2
2430
with:
25-
# Slow hooks are marked with manual - slow is okay here, run them too
26-
extra_args: --hook-stage manual --all-files
31+
path: ~/.cache/pre-commit
32+
key: pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
33+
restore-keys: pre-commit-
34+
35+
- name: Run pre-commit
36+
run: |
37+
# Slow hooks are marked with manual - slow is okay here, run them too
38+
pre-commit run --hook-stage manual --all-files
2739
2840
clang-tidy:
2941
name: Clang-Tidy

.github/workflows/publish_release.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
ref: 'master'
3232

3333
- name: Get history and tags for SCM versioning to work
34+
if: ${{ !env.ACT }}
3435
run: |
3536
git fetch --prune --unshallow
3637
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
@@ -69,19 +70,24 @@ jobs:
6970
7071
# ========================================================================
7172

72-
- name: Build source distribution
73+
- uses: actions/setup-python@v2
74+
75+
- name: Install Python packages
76+
run: python3 -m pip install -U pip setuptools build wheel
77+
78+
- name: Build source distribution (Linux)
7379
if: runner.os == 'Linux'
74-
run: python3 setup.py sdist -d wheelhouse
80+
run: python3 -m build --sdist
7581

7682
- name: Check metadata
7783
run: |
7884
python3 -m pip install twine --prefer-binary
79-
python3 -m twine check wheelhouse/*
85+
python3 -m twine check dist/*
8086
8187
- uses: actions/upload-artifact@v2
8288
with:
83-
name: packages
84-
path: ./wheelhouse/*
89+
name: pypy_wheels
90+
path: ./dist/*
8591

8692

8793
release:
@@ -134,8 +140,10 @@ jobs:
134140
ref: 'master'
135141

136142
# ------------------------------------------------------------------------
137-
# Downloads all to directories matching the artifact names
143+
138144
- uses: actions/download-artifact@v2
145+
with:
146+
name: pypy_wheels
139147

140148
# Code below inspired from this action:
141149
# - uses: taiki-e/create-gh-release-action@v1
@@ -160,7 +168,7 @@ jobs:
160168
if [[ "${tag}" =~ ^v?[0-9\.]+-[a-zA-Z_0-9\.-]+(\+[a-zA-Z_0-9\.-]+)?$ ]]; then
161169
prerelease="--prerelease"
162170
fi
163-
gh release create "v${RELEASE_VERSION}" ${prerelease:-} --title "ProjectQ v${RELEASE_VERSION}" --notes "${notes:-}" packages/*
171+
gh release create "v${RELEASE_VERSION}" ${prerelease:-} --title "ProjectQ v${RELEASE_VERSION}" --notes "${notes:-}" pypy_wheels/*
164172
165173
166174
upload_to_pypi:
@@ -170,15 +178,16 @@ jobs:
170178
steps:
171179
- uses: actions/setup-python@v2
172180

173-
# Downloads all to directories matching the artifact names
174181
- uses: actions/download-artifact@v2
182+
with:
183+
name: pypy_wheels
175184

176185
- name: Publish standard package
177186
uses: pypa/gh-action-pypi-publish@release/v1
178187
with:
179188
user: __token__
180189
password: ${{ secrets.pypi_password }}
181-
packages_dir: packages/
190+
packages_dir: pypy_wheels/
182191

183192
master_to_develop_pr:
184193
name: Merge master back into develop

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- id: check-useless-excludes
2424

2525
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v4.0.1
26+
rev: v4.1.0
2727
hooks:
2828
- id: check-added-large-files
2929
- id: check-case-conflict
@@ -44,21 +44,21 @@ repos:
4444
- id: remove-tabs
4545

4646
- repo: https://github.com/PyCQA/isort
47-
rev: 5.9.1
47+
rev: 5.10.1
4848
hooks:
4949
- id: isort
5050
name: isort (python)
5151

5252
- repo: https://github.com/psf/black
53-
rev: 21.5b1
53+
rev: 21.12b0
5454
hooks:
5555
- id: black
5656
language_version: python3
5757
# This is a slow hook, so only run this if --hook-stage manual is passed
5858
stages: [manual]
5959

6060
- repo: https://gitlab.com/PyCQA/flake8
61-
rev: 3.9.2
61+
rev: 4.0.1
6262
hooks:
6363
- id: flake8
6464
name: flake8-strict
@@ -82,7 +82,7 @@ repos:
8282
additional_dependencies: [pybind11>=2.6, numpy, requests, boto3, matplotlib, networkx, sympy]
8383

8484
- repo: https://github.com/mgedmin/check-manifest
85-
rev: '0.46'
85+
rev: '0.47'
8686
hooks:
8787
- id: check-manifest
8888
additional_dependencies: ['setuptools-scm', 'pybind11>=2.6']

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11+
12+
- Added environment variable to avoid -march=native when building ProjectQ
13+
- Added environment variable to force build failure if extensions do not compile on CI
14+
1115
### Changed
1216
### Deprecated
1317
### Fixed
18+
19+
- Fix compiler flags cleanup function for use on CI
20+
- Fix workflow YAML to allow execution of GitHub Actions locally using `act`
21+
- GitHub action using deprecated and vulnerable `pre-commit` version
22+
- Fixed issue with `gen_reqfile` command if `--include-extras` is not provided
23+
1424
### Removed
1525
### Repository
1626

27+
- Add configuration for CIBuildWheel in `pyproject.toml`
1728
- Update `thomaseizinger/keep-a-changelog-new-release` GiHub action to v1.3.0
1829
- Update `thomaseizinger/create-pull-request` GiHub action to v1.2.2
30+
- Update pre-commit hook `pre-commit/pre-commit-hooks` to v4.1.0
31+
- Update pre-commit hook `PyCQA/isort` to v5.10.1
32+
- Update pre-commit hook `psf/black` to v21.12b0
33+
- Update pre-commit hook `PyCQA/flake8` to v4.0.1
34+
- Update pre-commit hook `mgedmin/check-manifest` to v0.47
1935

2036
## [0.7.0] - 2021-07-14
2137

docs/tutorials.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ProjectQ comes with a high-performance quantum simulator written in C++. Please
2929
.. note::
3030
The setup will try to build a C++-Simulator, which is much faster than the Python implementation. If the C++ compilation were to fail, the setup will install a pure Python implementation of the simulator instead. The Python simulator should work fine for small examples (e.g., running Shor's algorithm for factoring 15 or 21).
3131

32-
If you want to skip the installation of the C++-Simulator altogether, you can define the ``DISABLE_PROJECTQ_CEXT`` environment variable to avoid any compilation steps.
32+
If you want to skip the installation of the C++-Simulator altogether, you can define the ``PROJECTQ_DISABLE_CEXT`` environment variable to avoid any compilation steps.
3333

3434
.. note::
3535
If building the C++-Simulator does not work out of the box, consider specifying a different compiler. For example:

pyproject.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,30 @@ local_scheme = 'no-local-version'
113113
[tool.yapf]
114114

115115
column_limit = 120
116+
117+
[tool.cibuildwheel]
118+
119+
archs = ['auto64']
120+
build-frontend = 'build'
121+
build-verbosity = 1
122+
skip = 'pp* *-musllinux*'
123+
environment = { PROJECTQ_DISABLE_ARCH_NATIVE='1', PROJECTQ_CI_BUILD='1' }
124+
125+
before-test = [
126+
'cd {package}',
127+
'python setup.py gen_reqfile',
128+
'python -m pip install -r requirements.txt --only-binary :all:',
129+
]
130+
131+
test-command = 'python3 {package}/examples/grover.py'
132+
133+
# Normal options, etc.
134+
manylinux-x86_64-image = 'manylinux2014'
135+
136+
[[tool.cibuildwheel.overrides]]
137+
select = 'cp36-*'
138+
manylinux-x86_64-image = 'manylinux1'
139+
140+
[[tool.cibuildwheel.overrides]]
141+
select = 'cp3{7,8,9}-*'
142+
manylinux-x86_64-image = 'manylinux2010'

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ classifier =
2424
Programming Language :: Python :: 3.7
2525
Programming Language :: Python :: 3.8
2626
Programming Language :: Python :: 3.9
27+
Programming Language :: Python :: 3.10
2728

2829
[options]
2930

0 commit comments

Comments
 (0)