-
Notifications
You must be signed in to change notification settings - Fork 194
Move setup.py metadata into pyproject.toml, remove dev-requirements.txt, & fix #839
#985
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
base: main
Are you sure you want to change the base?
Changes from 10 commits
18bffac
0f7a2b6
78383e1
2c77214
aedd475
c2d1d3a
59c8cb1
794c818
3b4102a
2a565d1
1363f94
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 | ||
|---|---|---|---|---|
|
|
@@ -38,21 +38,23 @@ COPY ./lib/ /qsim/lib/ | |||
| COPY ./pybind_interface/ /qsim/lib/ | ||||
| COPY ./qsimcirq_tests/ /qsim/qsimcirq_tests/ | ||||
| COPY ./requirements.txt /qsim/requirements.txt | ||||
| COPY ./dev-requirements.txt /qsim/dev-requirements.txt | ||||
| COPY ./pyproject.toml /qsim/pyproject.toml | ||||
|
|
||||
| # Create venv to avoid collision between system packages and what we install. | ||||
| RUN python3 -m venv --upgrade-deps test_env | ||||
| RUN python3 -m venv --upgrade-deps test_env && \ | ||||
| . test_env/bin/activate | ||||
|
Collaborator
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 am not very familiar with docker, but if every RUN invokes a new shell, the activate has no effect and can be dropped:
Suggested change
|
||||
|
|
||||
| WORKDIR /qsim/ | ||||
|
|
||||
| # Activate venv. | ||||
| ENV PATH="/test_env/bin:$PATH" | ||||
|
|
||||
| # Install qsim requirements. | ||||
| # hadolint ignore=DL3042 | ||||
| RUN python3 -m pip install -r /qsim/requirements.txt && \ | ||||
| python3 -m pip install -r /qsim/dev-requirements.txt | ||||
| # hadolint ignore=DL3013 | ||||
| RUN python3 -m pip install --no-cache-dir --upgrade pip && \ | ||||
|
Collaborator
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 think upgrade of pip should be unnecessary after |
||||
| python3 -m pip install --no-cache-dir -r requirements.txt | ||||
mhucka marked this conversation as resolved.
Dismissed
Show dismissed
Hide dismissed
mhucka marked this conversation as resolved.
Dismissed
Show dismissed
Hide dismissed
|
||||
|
|
||||
| # Compile qsim. | ||||
| WORKDIR /qsim/ | ||||
| RUN make -j qsim | ||||
|
|
||||
| ENTRYPOINT ["/qsim/apps/qsim_base.x"] | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| include requirements.txt | ||
| include dev-requirements.txt | ||
| include CMakeLists.txt | ||
|
|
||
| graft pybind_interface | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,18 +10,24 @@ directly in C++ code without building and installing the qsimcirq interface. | |
|
|
||
| ## Before installation | ||
|
|
||
| Prior to installation, consider opening a | ||
| Prior to installation, consider creating a | ||
| [virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/). | ||
|
|
||
| Prerequisites are included in the | ||
| Prerequisites for installing and running qsim are included in the | ||
| [`requirements.txt`](https://github.com/quantumlib/qsim/blob/main/requirements.txt) | ||
| file, and will be automatically installed along with qsimcirq. | ||
| file, and will be automatically installed along with qsimcirq when you install | ||
| it with pip. | ||
|
|
||
| If you'd like to develop qsimcirq, a separate set of dependencies are includes | ||
| If you'd like to develop qsimcirq, a separate set of dependencies are defined | ||
| in the | ||
| [`dev-requirements.txt`](https://github.com/quantumlib/qsim/blob/main/dev-requirements.txt) | ||
| file. You can install them with `pip3 install -r dev-requirements.txt` or | ||
| `pip3 install qsimcirq[dev]`. | ||
| [`pyproject.toml`](https://github.com/quantumlib/qsim/blob/main/pyproject.toml) | ||
| file. Using pip version 25.1 or higher, you can install them with the following | ||
| commands: | ||
|
|
||
| ```shell | ||
| pip install -r requirements.txt | ||
| pip install --group dev | ||
|
Comment on lines
+28
to
+29
Collaborator
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. consider joining these in one pip command. |
||
| ``` | ||
|
|
||
| ## Linux installation | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,28 +12,135 @@ | |||||||
| # See the License for the specific language governing permissions and | ||||||||
| # limitations under the License. | ||||||||
|
|
||||||||
| # Note: there are altogether 3 types of dependencies listed in this file: | ||||||||
| # | ||||||||
| # [build-system].requires: the packages needed for the build system. This list | ||||||||
| # is not stored in the package metadata. | ||||||||
| # | ||||||||
| # [project].dependencies: other packages are minimally needed to be able to | ||||||||
| # install and run qsimcirq. These are things like Cirq, NumPy, etc. Equivalent | ||||||||
| # to "install_requires" in setuptools' setup.py. The list gets stored in the | ||||||||
| # metadata of the package; when the project is installed by pip, this is the | ||||||||
| # specification that is used to install its dependencies. | ||||||||
| # | ||||||||
| # [dependency-groups].dev: the development dependencies; i.e., what a | ||||||||
| # developer needs in order to run unit tests, linters, and formatters. The | ||||||||
| # "[dependency-groups]" section is a Python packaging feature introduced in | ||||||||
| # 2025. This list is not stored in the metadata of the package. To install the | ||||||||
| # development dependencies, use "pip install --group dev". | ||||||||
|
|
||||||||
| [build-system] | ||||||||
| build-backend = "setuptools.build_meta" | ||||||||
| requires = [ | ||||||||
| "packaging", | ||||||||
| "setuptools>=78.1.1", | ||||||||
| "pybind11[global]", | ||||||||
| # "pip install" from sources needs to build Pybind, which needs CMake too. | ||||||||
| "cmake~=3.28.1", | ||||||||
| "setuptools>=78.1.1", | ||||||||
| "setuptools-scm[toml]>=6.2", | ||||||||
| "wheel", | ||||||||
| ] | ||||||||
| build-backend = "setuptools.build_meta" | ||||||||
|
|
||||||||
| [project] | ||||||||
| name = "qsimcirq" | ||||||||
| description = "High-performance quantum circuit simulator for C++ and Python." | ||||||||
| authors = [ | ||||||||
| { name = "The qsim/qsimh Developers", email = "[email protected]" } | ||||||||
| ] | ||||||||
| maintainers = [ | ||||||||
| { name = "Google Quantum AI", email = "[email protected]" } | ||||||||
| ] | ||||||||
| readme = {file = "README.md", content-type = "text/markdown"} | ||||||||
| license = "Apache-2.0" | ||||||||
| requires-python = ">=3.10.0" | ||||||||
| dynamic = ["version", "dependencies"] | ||||||||
| classifiers = [ | ||||||||
| "Development Status :: 5 - Production/Stable", | ||||||||
| "Environment :: GPU :: NVIDIA CUDA", | ||||||||
| "Intended Audience :: Developers", | ||||||||
| "Intended Audience :: Science/Research", | ||||||||
| "Operating System :: MacOS :: MacOS X", | ||||||||
| "Operating System :: Microsoft :: Windows", | ||||||||
| "Operating System :: POSIX :: Linux", | ||||||||
| "Programming Language :: C++", | ||||||||
| "Programming Language :: Python :: 3", | ||||||||
| "Programming Language :: Python :: 3.10", | ||||||||
| "Programming Language :: Python :: 3.11", | ||||||||
| "Programming Language :: Python :: 3.12", | ||||||||
| "Programming Language :: Python :: 3.13", | ||||||||
| "Topic :: Scientific/Engineering :: Quantum Computing", | ||||||||
| "Topic :: Software Development :: Libraries :: Python Modules", | ||||||||
| "Typing :: Typed", | ||||||||
| ] | ||||||||
| keywords = [ | ||||||||
| "algorithms", | ||||||||
| "cirq", | ||||||||
| "nisq", | ||||||||
| "quantum algorithm development", | ||||||||
| "quantum circuit simulator", | ||||||||
| "quantum computer simulator", | ||||||||
| "quantum computing", | ||||||||
| "quantum programming", | ||||||||
| "quantum simulation", | ||||||||
| "quantum", | ||||||||
| "schrödinger-feynman simulation", | ||||||||
| "simulation", | ||||||||
| "state vector simulator", | ||||||||
| ] | ||||||||
|
|
||||||||
| [project.urls] | ||||||||
| documentation = "https://quantumai.google/qsim" | ||||||||
| download = "https://pypi.org/project/qsimcirq/#files" | ||||||||
| homepage = "https://quantumai.google/qsim" | ||||||||
| issues = "https://github.com/quantumlib/qsim/issues" | ||||||||
| source = "https://github.com/quantumlib/qsim" | ||||||||
|
|
||||||||
| [dependency-groups] | ||||||||
| # Development dependencies. Install these with "pip install --group dev". | ||||||||
| dev = [ | ||||||||
| "black~=25.9.0", | ||||||||
| "cibuildwheel", | ||||||||
| # Distutils was removed from Python in 3.12. | ||||||||
| "setuptools; python_version >= '3.12'", | ||||||||
| "flynt~=1.0", | ||||||||
| "isort[colors]~=6.0.1", | ||||||||
| "py-cpuinfo", | ||||||||
| "pylint~=4.0.2", | ||||||||
| "pytest", | ||||||||
| "pytest-xdist", | ||||||||
| ] | ||||||||
|
|
||||||||
| [tool.setuptools] | ||||||||
| packages = ["qsimcirq"] | ||||||||
| package-data = {"qsimcirq" = ["py.typed"]} | ||||||||
|
|
||||||||
| [tool.setuptools.dynamic] | ||||||||
| # The next one becomes the value of [project].version. | ||||||||
| version = {attr = "qsimcirq._version.__version__"} | ||||||||
| # The next one becomes [project].dependencies, equivalent to "install_requires" | ||||||||
| # in setuptools' setup.py. "pip install qsim" installs these automatically. | ||||||||
| dependencies = {file = ["requirements.txt"] } | ||||||||
|
|
||||||||
| [tool.cibuildwheel] | ||||||||
| test-extras = "dev" | ||||||||
| build = "cp310-* cp311-* cp312-* cp313-*" | ||||||||
| dependency-versions = "latest" | ||||||||
| enable = ["cpython-prerelease"] | ||||||||
| environment.PIP_PREFER_BINARY = "1" | ||||||||
| # Due to package & module name conflict, temporarily move it away to run tests: | ||||||||
| before-test = "mv {package}/qsimcirq /tmp" | ||||||||
| test-command = "pytest -s -v {package}/qsimcirq_tests/qsimcirq_test.py && mv /tmp/qsimcirq {package}" | ||||||||
| before-test = "pip install --group dev && mv {package}/qsimcirq /tmp" | ||||||||
| test-command = """ | ||||||||
| pytest -s -v {package}/qsimcirq_tests/qsimcirq_test.py && | ||||||||
| mv /tmp/qsimcirq {package} | ||||||||
|
Comment on lines
+128
to
+129
Collaborator
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. If this is to prevent the import of
Suggested change
(should probably be in separate PR if you'd like to add it in). |
||||||||
| """ | ||||||||
|
|
||||||||
| [tool.cibuildwheel.macos] | ||||||||
| before-build = "brew install -q libomp llvm@19 && brew unlink libomp && brew unlink llvm@19 && brew link --force libomp && brew link --force llvm@19" | ||||||||
| repair-wheel-command = "delocate-listdeps {wheel} && delocate-wheel --verbose --require-archs {delocate_archs} -w {dest_dir} {wheel}" | ||||||||
| before-build = """ | ||||||||
| brew install -q libomp llvm@19 && | ||||||||
| brew unlink libomp && | ||||||||
| brew unlink llvm@19 && | ||||||||
| brew link --force libomp && | ||||||||
| brew link --force llvm@19 | ||||||||
| """ | ||||||||
| repair-wheel-command = """ | ||||||||
| delocate-listdeps {wheel} && | ||||||||
| delocate-wheel --verbose --require-archs {delocate_archs} -w {dest_dir} {wheel} | ||||||||
| """ | ||||||||
|
|
||||||||
| [tool.cibuildwheel.linux] | ||||||||
| manylinux-x86_64-image = "manylinux2014" | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| # Installation and run-time dependencies for qsimcirq. This file is read | ||
| # by pyproject.toml. | ||
|
|
||
| absl-py | ||
| cirq-core~=1.0 | ||
| numpy>=1.26.0 | ||
| numpy>=1.26.0,<2.0; python_version < '3.11' | ||
| numpy>=2.0; python_version >= '3.11' | ||
|
|
||
| # These are needed because installing qsimcirq in some environments may require | ||
| # pip to compile Pybind for that specific platform: | ||
| cmake~=3.28.1 | ||
| pybind11[global] | ||
|
Comment on lines
+9
to
+12
Collaborator
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. Should these be in
|
||
|
|
||
| # These are transitive dependencies we need to constrain to avoid unresolvable | ||
| # installation conflicts due to them requiring higher Python versions: | ||
| scipy<1.16; python_version < '3.11' | ||
| contourpy<1.3; python_version < '3.11' | ||
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.
I think it is better to run these together in one pip process.
That way any shared dependencies would need to resolve consistently for both requirements.txt and the dev group.