-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Move the compiled eccs to a separate package #517
Changes from all commits
24b3936
5f1a6ff
40755f2
fa6fb76
81b3e7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" |
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 |
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" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks strange. I think the [project] section below is what gets published to pypi, and this is what is used when you are pointing to the git repo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is abusing the inconsistent dependency definitions (see PR linked in the comment) to work around not being able to define local path + pypi dependencies.
When the wheels get built however their metadata is computed using |
||
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" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Python wheel artifacts | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Changelog |
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.
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" |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ See the [Getting Started][getting-started] guide and the other [examples]. | |
|
||
## Development | ||
|
||
This package uses [pyo3](https://pyo3.rs/v0.16.4/) and | ||
This package uses [pyo3](https://pyo3.rs/latest/) and | ||
[maturin](https://github.com/PyO3/maturin) to bind TKET2 functionality to | ||
python as the `tket2` package. | ||
|
||
|
@@ -56,4 +56,4 @@ See [DEVELOPMENT.md] for more information. | |
|
||
This project is licensed under Apache License, Version 2.0 ([LICENCE][] or http://www.apache.org/licenses/LICENSE-2.0). | ||
|
||
[LICENCE]: ./LICENCE | ||
[LICENCE]: https://github.com/CQCL/tket2/blob/main/LICENCE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer the other way, if LICENSE ever changed this would be wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to mention this. We need an absolute path. The LICENCE link on pypi's README is currently broken due to this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct because it matches the initial version in release-please-config.json. The robot will do the right thing here.