Skip to content

Commit 4823984

Browse files
google-labs-jules[bot]mhucka
authored andcommitted
Move most setup.py content into pyproject.toml
The modern approach is to put more things into `pyproject.toml`. This moves most things out of `setup.py`, with the exception of the native code extensions parts, and the version number. (Still to do: figure out how to move the version number too.)
1 parent 87e671c commit 4823984

File tree

2 files changed

+101
-85
lines changed

2 files changed

+101
-85
lines changed

pyproject.toml

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,100 @@
1313
# limitations under the License.
1414

1515
[build-system]
16+
build-backend = "setuptools.build_meta"
1617
requires = [
1718
"packaging",
1819
"setuptools>=78.1.1",
20+
"wheel",
1921
"pybind11[global]",
2022
# "pip install" from sources needs to build Pybind, which needs CMake too.
2123
"cmake~=3.28.1",
2224
]
23-
build-backend = "setuptools.build_meta"
25+
26+
[project]
27+
name = "qsimcirq"
28+
version = "0.23.0.dev0"
29+
description = "High-performance quantum circuit simulator for C++ and Python."
30+
authors = [
31+
{ name = "The qsim/qsimh Developers", email = "qsim-qsimh-dev@googlegroups.com" }
32+
]
33+
maintainers = [
34+
{ name = "Google Quantum AI", email = "quantum-oss-maintainers@google.com" }
35+
]
36+
license = "Apache-2.0"
37+
requires-python = ">=3.10.0"
38+
readme = "README.md"
39+
classifiers = [
40+
"Development Status :: 5 - Production/Stable",
41+
"Environment :: GPU :: NVIDIA CUDA",
42+
"Intended Audience :: Developers",
43+
"Intended Audience :: Science/Research",
44+
"Operating System :: MacOS :: MacOS X",
45+
"Operating System :: Microsoft :: Windows",
46+
"Operating System :: POSIX :: Linux",
47+
"Programming Language :: C++",
48+
"Programming Language :: Python :: 3",
49+
"Programming Language :: Python :: 3.10",
50+
"Programming Language :: Python :: 3.11",
51+
"Programming Language :: Python :: 3.12",
52+
"Programming Language :: Python :: 3.13",
53+
"Topic :: Scientific/Engineering :: Quantum Computing",
54+
"Topic :: Software Development :: Libraries :: Python Modules",
55+
"Typing :: Typed",
56+
]
57+
keywords = [
58+
"algorithms",
59+
"api",
60+
"application programming interface",
61+
"cirq",
62+
"google quantum",
63+
"google",
64+
"nisq",
65+
"python",
66+
"quantum algorithm development",
67+
"quantum circuit simulator",
68+
"quantum computer simulator",
69+
"quantum computing",
70+
"quantum computing research",
71+
"quantum programming",
72+
"quantum simulation",
73+
"quantum",
74+
"schrödinger-feynman simulation",
75+
"sdk",
76+
"simulation",
77+
"state vector simulator",
78+
"software development kit",
79+
]
80+
dependencies = [
81+
"absl-py",
82+
"cirq-core~=1.0",
83+
"numpy>=1.26.0",
84+
]
85+
86+
[project.optional-dependencies]
87+
dev = [
88+
"cmake~=3.28.1",
89+
"black~=25.9.0",
90+
"flynt~=1.0",
91+
"isort[colors]~=6.0.1",
92+
"pybind11[global]",
93+
"pylint~=4.0.2",
94+
"pytest",
95+
"pytest-xdist",
96+
"py-cpuinfo",
97+
"setuptools>=78.1.1",
98+
]
99+
100+
[project.urls]
101+
homepage = "https://quantumai.google/qsim"
102+
documentation = "https://quantumai.google/qsim"
103+
source = "https://github.com/quantumlib/qsim"
104+
download = "https://pypi.org/project/qsimcirq/#files"
105+
tracker = "https://github.com/quantumlib/qsim/issues"
106+
107+
[tool.setuptools]
108+
packages = ["qsimcirq"]
109+
package-data = {"qsimcirq" = ["py.typed"]}
24110

25111
[tool.cibuildwheel]
26112
test-extras = "dev"
@@ -43,3 +129,11 @@ skip = "*musllinux*"
43129
[tool.black]
44130
target-version = ['py310', 'py311', 'py312', 'py313']
45131
extend-exclude = 'third_party'
132+
133+
[tool.isort]
134+
profile = 'black'
135+
order_by_type = false # Sort alphabetically, irrespective of case.
136+
skip_gitignore = true
137+
combine_as_imports = true
138+
known_first_party = ["cirq*"]
139+
extend_skip = ["__init__.py"]

setup.py

Lines changed: 6 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import os
1616
import platform
1717
import re
18-
import runpy
1918
import shutil
2019
import subprocess
2120
import sys
@@ -24,6 +23,8 @@
2423
from setuptools import Extension, setup
2524
from setuptools.command.build_ext import build_ext
2625

26+
__version__ = "0.23.0.dev0"
27+
2728

2829
class CMakeExtension(Extension):
2930
def __init__(self, name, sourcedir=""):
@@ -67,6 +68,8 @@ def build_extension(self, ext):
6768
"-DCMAKE_CUDA_COMPILER=nvcc",
6869
]
6970

71+
# Append additional CMake arguments from the environment variable.
72+
# This is e.g. used by cibuildwheel to force a certain C++ standard.
7073
additional_cmake_args = os.environ.get("CMAKE_ARGS", "")
7174
if additional_cmake_args:
7275
cmake_args += additional_cmake_args.split()
@@ -110,9 +113,7 @@ def build_extension(self, ext):
110113

111114
env = os.environ.copy()
112115
cxxflags = env.get("CXXFLAGS", "")
113-
env["CXXFLAGS"] = (
114-
f'{cxxflags} -DVERSION_INFO=\\"{self.distribution.get_version()}\\"'
115-
)
116+
env["CXXFLAGS"] = f'{cxxflags} -DVERSION_INFO=\\"{__version__}\\"'
116117
if not os.path.exists(self.build_temp):
117118
os.makedirs(self.build_temp)
118119
subprocess.check_call(
@@ -124,42 +125,7 @@ def build_extension(self, ext):
124125
)
125126

126127

127-
with open("requirements.txt") as f:
128-
requirements = [
129-
line.strip() for line in f if line.strip() and not line.strip().startswith("#")
130-
]
131-
with open("dev-requirements.txt") as f:
132-
dev_requirements = [
133-
line.strip() for line in f if line.strip() and not line.strip().startswith("#")
134-
]
135-
136-
description = "Schrödinger and Schrödinger-Feynman simulators for quantum circuits."
137-
138-
# README file as long_description.
139-
with open("README.md", encoding="utf-8") as f:
140-
long_description = f.read()
141-
142-
__version__ = runpy.run_path("qsimcirq/_version.py")["__version__"]
143-
if not __version__:
144-
raise ValueError("Version string cannot be empty")
145-
146128
setup(
147-
name="qsimcirq",
148-
version=__version__,
149-
url="https://github.com/quantumlib/qsim",
150-
author="The qsim/qsimh Developers",
151-
author_email="qsim-qsimh-dev@googlegroups.com",
152-
maintainer="Google Quantum AI",
153-
maintainer_email="quantum-oss-maintainers@google.com",
154-
python_requires=">=3.10.0",
155-
install_requires=requirements,
156-
extras_require={
157-
"dev": dev_requirements,
158-
},
159-
license="Apache-2.0",
160-
description=description,
161-
long_description=long_description,
162-
long_description_content_type="text/markdown",
163129
ext_modules=[
164130
CMakeExtension("qsimcirq/qsim_avx512"),
165131
CMakeExtension("qsimcirq/qsim_avx2"),
@@ -170,49 +136,5 @@ def build_extension(self, ext):
170136
CMakeExtension("qsimcirq/qsim_decide"),
171137
CMakeExtension("qsimcirq/qsim_hip"),
172138
],
173-
cmdclass=dict(build_ext=CMakeBuild),
174-
zip_safe=False,
175-
packages=["qsimcirq"],
176-
package_data={"qsimcirq": ["py.typed"]},
177-
classifiers=[
178-
"Development Status :: 5 - Production/Stable",
179-
"Environment :: GPU :: NVIDIA CUDA",
180-
"Intended Audience :: Developers",
181-
"Intended Audience :: Science/Research",
182-
"Operating System :: MacOS :: MacOS X",
183-
"Operating System :: Microsoft :: Windows",
184-
"Operating System :: POSIX :: Linux",
185-
"Programming Language :: C++",
186-
"Programming Language :: Python :: 3",
187-
"Programming Language :: Python :: 3.10",
188-
"Programming Language :: Python :: 3.11",
189-
"Programming Language :: Python :: 3.12",
190-
"Programming Language :: Python :: 3.13",
191-
"Topic :: Scientific/Engineering :: Quantum Computing",
192-
"Topic :: Software Development :: Libraries :: Python Modules",
193-
"Typing :: Typed",
194-
],
195-
keywords=[
196-
"algorithms",
197-
"api",
198-
"application programming interface",
199-
"cirq",
200-
"google quantum",
201-
"google",
202-
"nisq",
203-
"python",
204-
"quantum algorithm development",
205-
"quantum circuit simulator",
206-
"quantum computer simulator",
207-
"quantum computing",
208-
"quantum computing research",
209-
"quantum programming",
210-
"quantum simulation",
211-
"quantum",
212-
"schrödinger-feynman simulation",
213-
"sdk",
214-
"simulation",
215-
"state vector simulator",
216-
"software development kit",
217-
],
139+
cmdclass={"build_ext": CMakeBuild},
218140
)

0 commit comments

Comments
 (0)