Skip to content

Commit

Permalink
✨ switch to mqt-core Python package (#418)
Browse files Browse the repository at this point in the history
## Description

This PR switches the project to use the newly developed `mqt-core`
Python package.
Any Python package build will only require the `mqt-core` package as a
build and runtime dependency and won't have to rely on fetched version
of mqt-core any more.
Any regular C++ build will still use the `FetchContent` CMake module.

The change brings a range of advantages:
- Uses the new `load` function of `mqt-core` that allows to load any
supported circuit format as input and has better handling for Qiskit
`QuantumCircuit` objects.
- Allows to directly feed QASM strings as inputs to the compilation
methods
- Simplifies the interfaces of the QMAP Python bindings
- Allows OpenQASM3 as an input format.

## Checklist:

<!---
This checklist serves as a reminder of a couple of things that ensure
your pull request will be merged swiftly.
-->

- [x] The pull request only contains commits that are related to it.
- [x] I have added appropriate tests and documentation.
- [x] I have made sure that all CI jobs on GitHub pass.
- [x] The pull request introduces no new warnings and follows the
project's style guidelines.
  • Loading branch information
burgholzer authored Feb 22, 2025
2 parents 3b7c97b + 0d125cd commit 2a4b9f5
Show file tree
Hide file tree
Showing 62 changed files with 1,672 additions and 1,162 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FormatStyle: file

Checks: |
boost-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-unchecked-optional-access,
Expand Down
36 changes: 4 additions & 32 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: CD
name: CD 🚀
on:
push:
branches: [main]
release:
types: [published]
workflow_dispatch:
Expand All @@ -13,41 +11,17 @@ permissions:

jobs:
# Builds the sdist and wheels on all supported platforms and uploads the resulting
# wheels as GitHub artifacts `dev-cibw-*`, `test-cibw-*`, or `cibw-*`, depending on
# whether the workflow is triggered from a PR, a push to main, or a release, respectively.
# wheels as GitHub artifacts `dev-cibw-*` or `cibw-*`, depending on whether the
# workflow is triggered from a PR or a release, respectively.
python-packaging:
name: 🐍 Packaging
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.7
with:
# Do not include local version information on pushes to main to facilitate TestPyPI uploads.
no-local-version: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
# Do not build emulated wheels on pushes to main to reduce runner load for CD.
build-emulated-wheels: ${{ github.ref != 'refs/heads/main' || github.event_name != 'push' }}
# Make sure Z3 is available
setup-z3: true
# 4.13.0 has incorrectly tagged manylinux wheels
z3-version: 4.12.6

# Downloads the previously generated artifacts and deploys to TestPyPI on pushes to main
deploy-test-pypi:
name: 🚀 Deploy to Test PyPI
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/mqt.qmap
needs: [python-packaging]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v4
with:
pattern: test-cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
attestations: true

# Downloads the previously generated artifacts and deploys to PyPI on published releases.
deploy:
if: github.event_name == 'release' && github.event.action == 'published'
Expand All @@ -68,5 +42,3 @@ jobs:
with:
subject-path: "dist/*"
- uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
168 changes: 162 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,181 @@ concurrency:
jobs:
change-detection:
name: 🔍 Change
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.7

cpp-tests:
name: 🇨‌ Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-tests)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
# Runs to enable
enable-ubuntu2404-gcc-release: true
enable-ubuntu2404-arm-gcc-release: true
enable-macos13-clang-release: true
enable-macos14-clang-release: true
enable-windows2022-msvc-release: true
# Runs to disable
enable-ubuntu2404-gcc-debug: false
enable-ubuntu2404-clang-release: false
enable-ubuntu2404-clang-debug: false
enable-ubuntu2204-gcc-release: false
enable-ubuntu2204-gcc-debug: false
enable-ubuntu2204-clang-release: false
enable-ubuntu2204-clang-debug: false
enable-ubuntu2404-arm-gcc-debug: false
enable-ubuntu2404-arm-clang-release: false
enable-ubuntu2404-arm-clang-debug: false
enable-ubuntu2204-arm-gcc-release: false
enable-ubuntu2204-arm-gcc-debug: false
enable-ubuntu2204-arm-clang-release: false
enable-ubuntu2204-arm-clang-debug: false
enable-macos13-clang-debug: false
enable-macos13-gcc-release: false
enable-macos13-gcc-debug: false
enable-macos14-clang-debug: false
enable-macos14-gcc-release: false
enable-macos14-gcc-debug: false
enable-macos15-clang-release: false
enable-macos15-clang-debug: false
enable-macos15-gcc-release: false
enable-macos15-gcc-debug: false
enable-windows2022-msvc-debug: false
enable-windows2022-clang-release: false
enable-windows2022-clang-debug: false
enable-windows2025-msvc-release: false
enable-windows2025-msvc-debug: false
enable-windows2025-clang-release: false
enable-windows2025-clang-debug: false
# General settings
setup-z3: true

# run extensive C++ tests whenever this is on a PR and the PR has the `extensive-cpp-ci` label
cpp-tests-extensive:
name: 🇨‌ Test (Extensive)
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-tests) && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'extensive-cpp-ci')
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
# Runs to enable
enable-ubuntu2404-gcc-debug: true
enable-ubuntu2404-clang-release: true
enable-ubuntu2404-clang-debug: true
enable-ubuntu2204-gcc-release: true
enable-ubuntu2204-gcc-debug: true
enable-ubuntu2204-clang-release: true
enable-ubuntu2204-clang-debug: true
enable-ubuntu2404-arm-gcc-debug: true
enable-ubuntu2404-arm-clang-release: true
enable-ubuntu2404-arm-clang-debug: true
enable-ubuntu2204-arm-gcc-release: true
enable-ubuntu2204-arm-gcc-debug: true
enable-ubuntu2204-arm-clang-release: true
enable-ubuntu2204-arm-clang-debug: true
enable-macos13-clang-debug: true
enable-macos13-gcc-release: true
enable-macos13-gcc-debug: true
enable-macos14-clang-debug: true
enable-macos14-gcc-release: true
enable-macos14-gcc-debug: true
enable-macos15-clang-release: true
enable-macos15-clang-debug: true
enable-macos15-gcc-release: true
enable-macos15-gcc-debug: true
enable-windows2022-msvc-debug: true
enable-windows2022-clang-release: true
enable-windows2022-clang-debug: true
enable-windows2025-msvc-release: true
enable-windows2025-msvc-debug: true
enable-windows2025-clang-release: true
enable-windows2025-clang-debug: true
# Runs to disable (these are already enabled in the non-extensive run)
enable-ubuntu2404-gcc-release: false
enable-ubuntu2404-arm-gcc-release: false
enable-macos13-clang-release: false
enable-macos14-clang-release: false
enable-windows2022-msvc-release: false
# General settings
setup-z3: true

cpp-coverage:
name: 🇨‌ Coverage
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-tests)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
setup-z3: true

cpp-linter:
name: 🇨‌ Lint
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-linter)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-linter.yml@v1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-linter.yml@v1.7
with:
setup-z3: true

# run extensive Python tests whenever this is on a PR and the PR has the `extensive-python-ci` label
python-tests:
name: 🐍 Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-tests)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
# Runs to enable
enable-ubuntu2404: true
enable-ubuntu2404-arm: true
enable-macos13: true
enable-macos14: true
enable-windows2022: true
# Runs to disable
enable-ubuntu2204: false
enable-ubuntu2204-arm: false
enable-macos15: false
enable-windows2025: false
# General settings
setup-z3: true

python-tests-extensive:
name: 🐍 Test (Extensive)
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-tests) && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'extensive-python-ci')
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
# Runs to enable
enable-ubuntu2204: true
enable-ubuntu2204-arm: true
enable-macos15: true
enable-windows2025: true
# Runs to disable (these are already enabled in the non-extensive run)
enable-ubuntu2404: false
enable-ubuntu2404-arm: false
enable-macos13: false
enable-macos14: false
enable-windows2022: false
# General settings
setup-z3: true

python-linter:
name: 🐍 Lint
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-tests)
uses: cda-tum/mqt-workflows/.github/workflows/[email protected]
with:
setup-z3: true

code-ql:
name: 📝 CodeQL
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-code-ql)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-code-ql.yml@v1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-code-ql.yml@v1.7
with:
setup-z3: true

cd:
name: 🚀 CD
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cd)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.7
with:
setup-z3: true
# 4.13.0 has incorrectly tagged manylinux wheels
Expand All @@ -64,8 +200,12 @@ jobs:
needs:
- change-detection
- cpp-tests
- cpp-tests-extensive
- cpp-coverage
- cpp-linter
- python-tests
- python-tests-extensive
- python-linter
- code-ql
- cd
runs-on: ubuntu-latest
Expand All @@ -78,6 +218,14 @@ jobs:
fromJSON(needs.change-detection.outputs.run-cpp-tests)
&& '' || 'cpp-tests,'
}}
${{
fromJSON(needs.change-detection.outputs.run-cpp-tests) && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'extensive-cpp-ci')
&& '' || 'cpp-tests-extensive,'
}}
${{
fromJSON(needs.change-detection.outputs.run-cpp-tests)
&& '' || 'cpp-coverage,'
}}
${{
fromJSON(needs.change-detection.outputs.run-cpp-linter)
&& '' || 'cpp-linter,'
Expand All @@ -86,6 +234,14 @@ jobs:
fromJSON(needs.change-detection.outputs.run-python-tests)
&& '' || 'python-tests,'
}}
${{
fromJSON(needs.change-detection.outputs.run-python-tests) && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'extensive-python-ci')
&& '' || 'python-tests-extensive,'
}}
${{
fromJSON(needs.change-detection.outputs.run-python-tests)
&& '' || 'python-linter,'
}}
${{
fromJSON(needs.change-detection.outputs.run-code-ql)
&& '' || 'code-ql,'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-mqt-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ concurrency:
jobs:
update-mqt-core:
name: ⬆️ Update MQT Core
uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.5
uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.7
with:
update-to-head: ${{ github.event.inputs.update-to-head == 'true' }}
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ repos:

# Python linting using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
rev: v0.9.7
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -86,10 +86,11 @@ repos:
- pytest
- rustworkx
- mqt.qcec
- mqt.core>=3.0.0b4

# Check for spelling
- repo: https://github.com/crate-ci/typos
rev: v1.29.4
rev: v1.29.9
hooks:
- id: typos

Expand Down Expand Up @@ -127,21 +128,21 @@ repos:

# Check best practices for scientific Python code
- repo: https://github.com/scientific-python/cookie
rev: 2024.08.19
rev: 2025.01.22
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]

# Check JSON schemata
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.31.1
rev: 0.31.2
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs

# Check the pyproject.toml file
- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2024.11.25
rev: 2025.02.17
hooks:
- id: validate-pyproject
Loading

0 comments on commit 2a4b9f5

Please sign in to comment.