Skip to content

Commit 7247cc6

Browse files
authored
feat: Move the compiled eccs to a separate package (#517)
Closes #486. We should merge this before publishing the next alpha. I checked that the [generated wheels](https://github.com/CQCL/tket2/actions/runs/10166482192/job/28116748310) for `tket2-py` contain the correct (non-local) dependency on `tket2_eccs`. The pure-python wheels ci job is copied from [`hugr-py`](https://github.com/CQCL/hugr/blob/dd1dc484447cc2180058f4474594ddb51fa45cd6/.github/workflows/python-wheels.yml).
1 parent bd06805 commit 7247cc6

22 files changed

+263
-23
lines changed

.github/change-filters.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ rust:
1515
python:
1616
- *rust-core
1717
- "tket2-py/**"
18+
- "tket2-eccs/**"
1819
- "pyproject.toml"
1920
- "poetry.lock"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and publish pure python wheels
2+
# Builds and publishes the pure wheels on pypi.
3+
#
4+
# This does not include the main `tket2-py` package, which is built using maturin.
5+
# See `python-wheels.yml` for that workflow.
6+
#
7+
# When running on a release event or as a workflow dispatch for a tag,
8+
# and if the tag matches `{package}-v*`,
9+
# this workflow will publish the wheels to pypi.
10+
# If the version is already published, pypi just ignores it.
11+
12+
on:
13+
workflow_dispatch:
14+
push:
15+
branches:
16+
- main
17+
release:
18+
types:
19+
- published
20+
21+
jobs:
22+
build-publish:
23+
name: Build and publish wheels
24+
runs-on: ubuntu-latest
25+
strategy:
26+
matrix:
27+
package:
28+
- 'tket2-eccs'
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Run sccache-cache
33+
uses: mozilla-actions/sccache-action@v0.0.5
34+
- name: Install poetry
35+
run: pipx install poetry
36+
- name: Set up Python '3.10'
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.10'
40+
cache: "poetry"
41+
42+
- name: Build sdist and wheels
43+
run: |
44+
cd ${{ matrix.package }}
45+
poetry build -o ../dist
46+
47+
- name: Upload the built packages as artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: build-${{ matrix.package }}-sdist
51+
path: |
52+
dist/*.tar.gz
53+
dist/*.whl
54+
55+
- name: Publish to PyPI
56+
if: ${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.package)) ) || (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, format('refs/tags/{0}-v', matrix.package)) ) }}
57+
run: |
58+
cd ${{ matrix.package }}
59+
poetry config pypi-token.pypi ${{ secrets.PYPI_PUBLISH }}
60+
poetry publish --dist-dir ../dist --skip-existing

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ repos:
8585
- id: py-test
8686
name: pytest
8787
description: Run python tests
88-
entry: poetry run -- sh -c "maturin develop && pytest --cov=./ --cov-report=html"
88+
# Ensure that we are using the local version of `tket2-eccs` and not the one from PyPI
89+
entry: poetry run -- sh -c "poetry install -C tket2-eccs && maturin develop && pytest --cov=./ --cov-report=html"
8990
language: system
9091
files: \.py$
9192
pass_filenames: false

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"tket2-py": "0.1.0a4"
2+
"tket2-py": "0.1.0a4",
3+
"tket2-eccs": "0.0.0"
34
}

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ urlencoding = "2.1.2"
6868
webbrowser = "1.0.0"
6969
cool_asserts = "2.0.3"
7070
zstd = "0.13.2"
71+
72+
[profile.release.package.tket2-py]
73+
# Some configurations to reduce the size of tket2 wheels
74+
strip = true

justfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ check:
1414

1515
# Compile the wheels for the python package.
1616
build:
17+
#!/usr/bin/env bash
18+
set -euo pipefail
19+
# Ensure that we are using the local version of `pytket-eccs`
20+
poetry install -C tket2-eccs
1721
poetry run -- maturin build --release
1822

1923
# Run all the tests.
2024
test language="[rust|python]" : (_run_lang language \
2125
"poetry run cargo test --all-features --workspace" \
22-
"poetry run maturin develop && poetry run pytest"
26+
"poetry install -C tket2-eccs && poetry run maturin develop && poetry run pytest"
2327
)
2428

2529
# Auto-fix all clippy warnings.
@@ -37,7 +41,7 @@ format language="[rust|python]": (_run_lang language \
3741
# Generate a test coverage report.
3842
coverage language="[rust|python]": (_run_lang language \
3943
"poetry run -- cargo llvm-cov --lcov > lcov.info" \
40-
"poetry run -- maturin develop && poetry run pytest --cov=./ --cov-report=html"
44+
"poetry install -C tket2-eccs && poetry run -- maturin develop && poetry run pytest --cov=./ --cov-report=html"
4145
)
4246

4347
# Load a shell with all the dependencies installed

poetry.lock

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "tket2-py"
33
version = "0.1.0a4"
4-
description = "pytket extension for the tket 2 compiler"
4+
description = "Quantinuum's TKET2 Quantum Compiler"
55
classifiers = [
66
"Environment :: Console",
77
"Programming Language :: Python :: 3.10",
@@ -25,10 +25,12 @@ packages = [{ include = "tket2-py" }]
2525

2626
[tool.poetry.dependencies]
2727
python = "^3.10"
28+
2829
# Note: Be sure to update the dependency versions in [project.dependencies] as well
2930
#
3031
# Poetry does not currently follow PEP 621, it will be supported on poetry 2
3132
# https://github.com/python-poetry/poetry/issues/3332
33+
tket2_eccs = { path = "tket2-eccs", develop = true }
3234
pytket = "1.30.0"
3335
hugr = "^0.5.0"
3436

@@ -68,12 +70,16 @@ maintainers = [
6870
{ name = "TKET development team", email = "tket-support@quantinuum.com" },
6971
]
7072
version = "0.1.0a4"
71-
description = "pytket extension for the tket 2 compiler"
73+
description = "Quantinuum's TKET2 Quantum Compiler"
7274
requires-python = ">=3.10"
7375
license = { file = "LICENCE" }
7476

7577
# Note: Be sure to update the dependency versions in [tool.poetry.dependencies] as well
76-
dependencies = ['pytket >= 1.29.2, < 2', 'hugr >= 0.5.0, < 0.6']
78+
dependencies = [
79+
'pytket >= 1.29.2, < 2',
80+
'hugr >= 0.5.0, < 0.6',
81+
'tket2_eccs >= 0.1.0, < 0.2',
82+
]
7783

7884
[project.urls]
7985
homepage = "https://github.com/CQCL/tket2"

release-please-config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
"draft": false,
1414
"prerelease": false,
1515
"draft-pull-request": true
16+
},
17+
"tket2-eccs": {
18+
"release-type": "python",
19+
"component": "tket2-eccs",
20+
"package-name": "tket2_eccs",
21+
"include-component-in-tag": true,
22+
"draft": false,
23+
"prerelease": false,
24+
"draft-pull-request": true
1625
}
1726
},
1827
"changelog-sections": [

scripts/compile-test-eccs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ done
2323
# Additional hard-coded step:
2424
# The python package contains a copy of the nam_6_3 ecc,
2525
# which must be manually copied.
26-
PY_ECCS_DIR="$DIR/../tket2-py/tket2/data"
26+
PY_ECCS_DIR="$DIR/../tket2-eccs/src/tket2_eccs/data"
2727
nam_6_3="$ECCS_DIR/nam_6_3.rwr"
2828
PY_NAM_6_3="$PY_ECCS_DIR/nam_6_3.rwr"
2929

0 commit comments

Comments
 (0)