-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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).
- Loading branch information
Showing
22 changed files
with
263 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,6 @@ rust: | |
python: | ||
- *rust-core | ||
- "tket2-py/**" | ||
- "tket2-eccs/**" | ||
- "pyproject.toml" | ||
- "poetry.lock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build and publish pure python wheels | ||
# Builds and publishes the pure wheels on pypi. | ||
# | ||
# This does not include the main `tket2-py` package, which is built using maturin. | ||
# See `python-wheels.yml` for that workflow. | ||
# | ||
# When running on a release event or as a workflow dispatch for a tag, | ||
# and if the tag matches `{package}-v*`, | ||
# this workflow will publish the wheels to pypi. | ||
# If the version is already published, pypi just ignores it. | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build-publish: | ||
name: Build and publish wheels | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
package: | ||
- 'tket2-eccs' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python '3.10' | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
cache: "poetry" | ||
|
||
- name: Build sdist and wheels | ||
run: | | ||
cd ${{ matrix.package }} | ||
poetry build -o ../dist | ||
- name: Upload the built packages as artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-${{ matrix.package }}-sdist | ||
path: | | ||
dist/*.tar.gz | ||
dist/*.whl | ||
- name: Publish to PyPI | ||
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)) ) }} | ||
run: | | ||
cd ${{ matrix.package }} | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_PUBLISH }} | ||
poetry publish --dist-dir ../dist --skip-existing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"tket2-py": "0.1.0a4" | ||
"tket2-py": "0.1.0a4", | ||
"tket2-eccs": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[tool.poetry] | ||
name = "tket2-py" | ||
version = "0.1.0a4" | ||
description = "pytket extension for the tket 2 compiler" | ||
description = "Quantinuum's TKET2 Quantum Compiler" | ||
classifiers = [ | ||
"Environment :: Console", | ||
"Programming Language :: Python :: 3.10", | ||
|
@@ -25,10 +25,12 @@ packages = [{ include = "tket2-py" }] | |
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
|
||
# Note: Be sure to update the dependency versions in [project.dependencies] as well | ||
# | ||
# Poetry does not currently follow PEP 621, it will be supported on poetry 2 | ||
# https://github.com/python-poetry/poetry/issues/3332 | ||
tket2_eccs = { path = "tket2-eccs", develop = true } | ||
pytket = "1.30.0" | ||
hugr = "^0.5.0" | ||
|
||
|
@@ -68,12 +70,16 @@ maintainers = [ | |
{ name = "TKET development team", email = "[email protected]" }, | ||
] | ||
version = "0.1.0a4" | ||
description = "pytket extension for the tket 2 compiler" | ||
description = "Quantinuum's TKET2 Quantum Compiler" | ||
requires-python = ">=3.10" | ||
license = { file = "LICENCE" } | ||
|
||
# Note: Be sure to update the dependency versions in [tool.poetry.dependencies] as well | ||
dependencies = ['pytket >= 1.29.2, < 2', 'hugr >= 0.5.0, < 0.6'] | ||
dependencies = [ | ||
'pytket >= 1.29.2, < 2', | ||
'hugr >= 0.5.0, < 0.6', | ||
'tket2_eccs >= 0.1.0, < 0.2', | ||
] | ||
|
||
[project.urls] | ||
homepage = "https://github.com/CQCL/tket2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Python wheel artifacts | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# tket2-eccs | ||
|
||
[![pypi][]](https://pypi.org/project/tket2/) | ||
[![codecov][]](https://codecov.io/gh/CQCL/tket2) | ||
[![py-version][]](https://pypi.org/project/tket2/) | ||
|
||
[codecov]: https://img.shields.io/codecov/c/gh/CQCL/tket2?logo=codecov | ||
[py-version]: https://img.shields.io/pypi/pyversions/tket2 | ||
[pypi]: https://img.shields.io/pypi/v/tket2 | ||
|
||
This is an auxiliary Python package containing compiler rewrite sets used for `tket2`'s optimisation passes. | ||
|
||
This package is intended to be used as an internal dependency for `tket2`. | ||
See https://pypi.org/project/tket2/ for the main package. | ||
|
||
|
||
## Install | ||
|
||
TKET2-eccs can be installed via `pip`. | ||
|
||
```sh | ||
pip install tket2_eccs | ||
``` | ||
|
||
## Development | ||
|
||
See [DEVELOPMENT.md] information on how to develop and contribute to this package. | ||
|
||
[DEVELOPMENT.md]: https://github.com/CQCL/tket2/blob/main/DEVELOPMENT.md | ||
|
||
|
||
## License | ||
|
||
This project is licensed under Apache License, Version 2.0 ([LICENCE][] or http://www.apache.org/licenses/LICENSE-2.0). | ||
|
||
[LICENCE]: https://github.com/CQCL/tket2/blob/main/LICENCE |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
[tool.poetry] | ||
name = "tket2-eccs" | ||
version = "0.1.0" | ||
description = "Precompiled rewrite sets for the tket 2 compiler" | ||
classifiers = [ | ||
"Environment :: Console", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: MacOS :: MacOS X", | ||
"Operating System :: POSIX :: Linux", | ||
"Operating System :: Microsoft :: Windows", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"Topic :: Scientific/Engineering", | ||
] | ||
authors = ["TKET development team <[email protected]>"] | ||
maintainers = ["TKET development team <[email protected]>"] | ||
include = ["pyproject.toml"] | ||
license = "Apache-2.0" | ||
readme = "README.md" | ||
|
||
packages = [{ include = "tket2_eccs", from = "src" }] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[project] | ||
name = "tket2_eccs" | ||
classifiers = [ | ||
"Environment :: Console", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Operating System :: MacOS :: MacOS X", | ||
"Operating System :: POSIX :: Linux", | ||
"Operating System :: Microsoft :: Windows", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"Topic :: Scientific/Engineering", | ||
] | ||
authors = [ | ||
{ name = "TKET development team", email = "[email protected]" }, | ||
] | ||
maintainers = [ | ||
{ name = "TKET development team", email = "[email protected]" }, | ||
] | ||
version = "0.1.0" | ||
description = "Precompiled rewrite sets for the tket 2 compiler" | ||
requires-python = ">=3.10" | ||
license = { file = "LICENCE" } | ||
|
||
dependencies = [] | ||
|
||
[project.urls] | ||
homepage = "https://github.com/CQCL/tket2" | ||
repository = "https://github.com/CQCL/tket2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""`tket2-eccs` is a Python package containing compiler rewrite sets used for `tket2`'s optimisation passes. | ||
This package is intended to be used as an internal dependency for `tket2`. | ||
""" | ||
|
||
# This is updated by our release-please workflow, triggered by this | ||
# annotation: x-release-please-version | ||
__version__ = "0.1.0" | ||
|
||
from importlib import resources | ||
from pathlib import Path | ||
|
||
|
||
def nam_6_3() -> Path: | ||
"""Get the path to the included `nam_6_3.rwr` rewriter. | ||
This is a rewrite set obtained from the equivalence classes of circuits with | ||
up to 3 qubits and 6 gates on the Nam gateset, as | ||
generated by TASO. | ||
See https://dl.acm.org/doi/10.1145/3341301.3359630 | ||
""" | ||
with resources.as_file( | ||
resources.files("tket2_eccs").joinpath("data/nam_6_3.rwr") | ||
) as r: | ||
rewriter = Path(r) | ||
return rewriter |
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.