-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ ship shared C++ libraries with mqt-core Python package (#662)
## Description This PR adapts the `mqt.core` Python package to also ship the complete MQT Core C++ library in a compact form so that the Python package can be used as the single source for the C++ and the Python side in top-level projects. In turn, the `mqt-core-python` target is (finally) removed, which was long overdue. Top-level projects are now expected to rely on the mqt-core Python package for importing circuits from Qiskit. To minimise the growth of the mqt-core Python wheels, Python package build will now build shared libraries as opposed to static libraries. The resulting wheels now have a couple megabytes, which should still be reasonable. However, to minimise the risk of running into space issues on PyPI further, this PR stops building emulated wheels for the `mqt-core` Python package. We have no real signs that people are using them in any meaningful way and they take forever to build. Hence, removing them seams like a win-win. Given the potential breaking nature of the discontinuation of the `mqt-core-python` target, the next release after this release is merged will be `v3.0`. I'd expect a couple more breaking changes to come in over the next couple of weeks before that release though. ## 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
Showing
13 changed files
with
264 additions
and
599 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
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
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
This file was deleted.
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
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
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,54 @@ | ||
# Copyright (c) 2025 Chair for Design Automation, TUM | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# Licensed under the MIT License | ||
|
||
"""Command line interface for mqt-core.""" | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
import sys | ||
|
||
from ._commands import cmake_dir, include_dir | ||
from ._version import version as __version__ | ||
|
||
|
||
def main() -> None: | ||
"""Entry point for the mqt-core command line interface. | ||
This function is called when running the `mqt-core-cli` script. | ||
.. code-block:: bash | ||
mqt-core-cli [--version] [--include_dir] [--cmake_dir] | ||
It provides the following command line options: | ||
- :code:`--version`: Print the version and exit. | ||
- :code:`--include_dir`: Print the path to the mqt-core C++ include directory. | ||
- :code:`--cmake_dir`: Print the path to the mqt-core CMake module directory. | ||
""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--version", action="version", version=__version__, help="Print version and exit.") | ||
|
||
parser.add_argument( | ||
"--include_dir", action="store_true", help="Print the path to the mqt-core C++ include directory." | ||
) | ||
parser.add_argument( | ||
"--cmake_dir", action="store_true", help="Print the path to the mqt-core CMake module directory." | ||
) | ||
args = parser.parse_args() | ||
if not sys.argv[1:]: | ||
parser.print_help() | ||
if args.include_dir: | ||
print(include_dir().resolve()) | ||
if args.cmake_dir: | ||
print(cmake_dir().resolve()) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,51 @@ | ||
# Copyright (c) 2025 Chair for Design Automation, TUM | ||
# All rights reserved. | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# Licensed under the MIT License | ||
|
||
"""Useful commands for obtaining information about mqt-core.""" | ||
|
||
from __future__ import annotations | ||
|
||
from importlib.metadata import PackageNotFoundError, distribution | ||
from pathlib import Path | ||
|
||
|
||
def include_dir() -> Path: | ||
"""Return the path to the mqt-core include directory. | ||
Raises: | ||
FileNotFoundError: If the include directory is not found. | ||
ImportError: If mqt-core is not installed. | ||
""" | ||
try: | ||
dist = distribution("mqt-core") | ||
located_include_dir = Path(dist.locate_file("mqt/core/include/mqt-core")) | ||
if located_include_dir.exists() and located_include_dir.is_dir(): | ||
return located_include_dir | ||
msg = "mqt-core include files not found." | ||
raise FileNotFoundError(msg) | ||
except PackageNotFoundError: | ||
msg = "mqt-core not installed, installation required to access the include files." | ||
raise ImportError(msg) from None | ||
|
||
|
||
def cmake_dir() -> Path: | ||
"""Return the path to the mqt-core CMake module directory. | ||
Raises: | ||
FileNotFoundError: If the CMake module directory is not found. | ||
ImportError: If mqt-core is not installed. | ||
""" | ||
try: | ||
dist = distribution("mqt-core") | ||
located_cmake_dir = Path(dist.locate_file("mqt/core/share/cmake")) | ||
if located_cmake_dir.exists() and located_cmake_dir.is_dir(): | ||
return located_cmake_dir | ||
msg = "mqt-core CMake files not found." | ||
raise FileNotFoundError(msg) | ||
except PackageNotFoundError: | ||
msg = "mqt-core not installed, installation required to access the CMake files." | ||
raise ImportError(msg) from None |
Oops, something went wrong.