Skip to content

Commit 0a9613d

Browse files
Fix(deps): Modernize packaging to fix setuptools deprecations
This commit addresses deprecation warnings originating from the use of outdated `setuptools` functions. To resolve this, the project's packaging configuration has been modernized in accordance with current Python packaging standards (PEP 621). Key changes include: - All declarative package metadata (e.g., name, version, dependencies, author, classifiers) has been moved from `setup.py` to `pyproject.toml`. - The `setup.py` file has been simplified to only contain the logic necessary for building the C++ extensions. - The deprecated `self.distribution.get_version()` method has been replaced with a direct use of the `__version__` variable. - The `py.typed` marker file is now correctly included in the package via the `[tool.setuptools.package-data]` configuration in `pyproject.toml`. These changes ensure that the build process is fully compliant with modern packaging standards and eliminates the `setuptools` deprecation warnings.
1 parent 87e671c commit 0a9613d

File tree

2 files changed

+86
-84
lines changed

2 files changed

+86
-84
lines changed

pyproject.toml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,89 @@
1616
requires = [
1717
"packaging",
1818
"setuptools>=78.1.1",
19+
"wheel",
1920
"pybind11[global]",
2021
# "pip install" from sources needs to build Pybind, which needs CMake too.
2122
"cmake~=3.28.1",
2223
]
2324
build-backend = "setuptools.build_meta"
2425

26+
[project]
27+
name = "qsimcirq"
28+
version = "0.23.0.dev0"
29+
description = "Schrödinger and Schrödinger-Feynman simulators for quantum circuits."
30+
readme = "README.md"
31+
authors = [{ name = "The qsim/qsimh Developers", email = "[email protected]" }]
32+
license = { text = "Apache-2.0" }
33+
classifiers = [
34+
"Development Status :: 5 - Production/Stable",
35+
"Environment :: GPU :: NVIDIA CUDA",
36+
"Intended Audience :: Developers",
37+
"Intended Audience :: Science/Research",
38+
"Operating System :: MacOS :: MacOS X",
39+
"Operating System :: Microsoft :: Windows",
40+
"Operating System :: POSIX :: Linux",
41+
"Programming Language :: C++",
42+
"Programming Language :: Python :: 3",
43+
"Programming Language :: Python :: 3.10",
44+
"Programming Language :: Python :: 3.11",
45+
"Programming Language :: Python :: 3.12",
46+
"Programming Language :: Python :: 3.13",
47+
"Topic :: Scientific/Engineering :: Quantum Computing",
48+
"Topic :: Software Development :: Libraries :: Python Modules",
49+
"Typing :: Typed",
50+
]
51+
keywords = [
52+
"algorithms",
53+
"api",
54+
"application programming interface",
55+
"cirq",
56+
"google quantum",
57+
"google",
58+
"nisq",
59+
"python",
60+
"quantum algorithm development",
61+
"quantum circuit simulator",
62+
"quantum computer simulator",
63+
"quantum computing",
64+
"quantum computing research",
65+
"quantum programming",
66+
"quantum simulation",
67+
"quantum",
68+
"schrödinger-feynman simulation",
69+
"sdk",
70+
"simulation",
71+
"state vector simulator",
72+
"software development kit",
73+
]
74+
requires-python = ">=3.10.0"
75+
dependencies = [
76+
"absl-py",
77+
"cirq-core~=1.0",
78+
"numpy>=1.26.0",
79+
]
80+
81+
[project.urls]
82+
Homepage = "https://github.com/quantumlib/qsim"
83+
84+
[project.optional-dependencies]
85+
dev = [
86+
"cmake~=3.28.1",
87+
"black~=25.9.0",
88+
"flynt~=1.0",
89+
"isort[colors]~=6.0.1",
90+
"pybind11[global]",
91+
"pylint~=4.0.2",
92+
"pytest",
93+
"pytest-xdist",
94+
"py-cpuinfo",
95+
"setuptools>=78.1.1",
96+
]
97+
98+
[tool.setuptools]
99+
packages = ["qsimcirq"]
100+
package-data = {"qsimcirq" = ["py.typed"]}
101+
25102
[tool.cibuildwheel]
26103
test-extras = "dev"
27104
dependency-versions = "latest"

setup.py

Lines changed: 9 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,11 @@
2423
from setuptools import Extension, setup
2524
from setuptools.command.build_ext import build_ext
2625

26+
# This file is largely based on the setup.py file at
27+
# https://github.com/pybind/cmake_example/blob/master/setup.py
28+
29+
__version__ = "0.23.0.dev0"
30+
2731

2832
class CMakeExtension(Extension):
2933
def __init__(self, name, sourcedir=""):
@@ -67,6 +71,8 @@ def build_extension(self, ext):
6771
"-DCMAKE_CUDA_COMPILER=nvcc",
6872
]
6973

74+
# Append additional CMake arguments from the environment variable.
75+
# This is e.g. used by cibuildwheel to force a certain C++ standard.
7076
additional_cmake_args = os.environ.get("CMAKE_ARGS", "")
7177
if additional_cmake_args:
7278
cmake_args += additional_cmake_args.split()
@@ -110,9 +116,7 @@ def build_extension(self, ext):
110116

111117
env = os.environ.copy()
112118
cxxflags = env.get("CXXFLAGS", "")
113-
env["CXXFLAGS"] = (
114-
f'{cxxflags} -DVERSION_INFO=\\"{self.distribution.get_version()}\\"'
115-
)
119+
env["CXXFLAGS"] = f'{cxxflags} -DVERSION_INFO=\\"{__version__}\\"'
116120
if not os.path.exists(self.build_temp):
117121
os.makedirs(self.build_temp)
118122
subprocess.check_call(
@@ -124,42 +128,7 @@ def build_extension(self, ext):
124128
)
125129

126130

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-
146131
setup(
147-
name="qsimcirq",
148-
version=__version__,
149-
url="https://github.com/quantumlib/qsim",
150-
author="The qsim/qsimh Developers",
151-
author_email="[email protected]",
152-
maintainer="Google Quantum AI",
153-
maintainer_email="[email protected]",
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",
163132
ext_modules=[
164133
CMakeExtension("qsimcirq/qsim_avx512"),
165134
CMakeExtension("qsimcirq/qsim_avx2"),
@@ -170,49 +139,5 @@ def build_extension(self, ext):
170139
CMakeExtension("qsimcirq/qsim_decide"),
171140
CMakeExtension("qsimcirq/qsim_hip"),
172141
],
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-
],
142+
cmdclass={"build_ext": CMakeBuild},
218143
)

0 commit comments

Comments
 (0)