From 482398437d24b15c51f8b9e13953810d28840ac9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 02:23:12 +0000 Subject: [PATCH] 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.) --- pyproject.toml | 96 +++++++++++++++++++++++++++++++++++++++++++++++++- setup.py | 90 ++++------------------------------------------ 2 files changed, 101 insertions(+), 85 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 37d71445..be61184d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,14 +13,100 @@ # limitations under the License. [build-system] +build-backend = "setuptools.build_meta" requires = [ "packaging", "setuptools>=78.1.1", + "wheel", "pybind11[global]", # "pip install" from sources needs to build Pybind, which needs CMake too. "cmake~=3.28.1", ] -build-backend = "setuptools.build_meta" + +[project] +name = "qsimcirq" +version = "0.23.0.dev0" +description = "High-performance quantum circuit simulator for C++ and Python." +authors = [ + { name = "The qsim/qsimh Developers", email = "qsim-qsimh-dev@googlegroups.com" } +] +maintainers = [ + { name = "Google Quantum AI", email = "quantum-oss-maintainers@google.com" } +] +license = "Apache-2.0" +requires-python = ">=3.10.0" +readme = "README.md" +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", + "api", + "application programming interface", + "cirq", + "google quantum", + "google", + "nisq", + "python", + "quantum algorithm development", + "quantum circuit simulator", + "quantum computer simulator", + "quantum computing", + "quantum computing research", + "quantum programming", + "quantum simulation", + "quantum", + "schrödinger-feynman simulation", + "sdk", + "simulation", + "state vector simulator", + "software development kit", +] +dependencies = [ + "absl-py", + "cirq-core~=1.0", + "numpy>=1.26.0", +] + +[project.optional-dependencies] +dev = [ + "cmake~=3.28.1", + "black~=25.9.0", + "flynt~=1.0", + "isort[colors]~=6.0.1", + "pybind11[global]", + "pylint~=4.0.2", + "pytest", + "pytest-xdist", + "py-cpuinfo", + "setuptools>=78.1.1", +] + +[project.urls] +homepage = "https://quantumai.google/qsim" +documentation = "https://quantumai.google/qsim" +source = "https://github.com/quantumlib/qsim" +download = "https://pypi.org/project/qsimcirq/#files" +tracker = "https://github.com/quantumlib/qsim/issues" + +[tool.setuptools] +packages = ["qsimcirq"] +package-data = {"qsimcirq" = ["py.typed"]} [tool.cibuildwheel] test-extras = "dev" @@ -43,3 +129,11 @@ skip = "*musllinux*" [tool.black] target-version = ['py310', 'py311', 'py312', 'py313'] extend-exclude = 'third_party' + +[tool.isort] +profile = 'black' +order_by_type = false # Sort alphabetically, irrespective of case. +skip_gitignore = true +combine_as_imports = true +known_first_party = ["cirq*"] +extend_skip = ["__init__.py"] diff --git a/setup.py b/setup.py index 328b27cd..9f53a272 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,6 @@ import os import platform import re -import runpy import shutil import subprocess import sys @@ -24,6 +23,8 @@ from setuptools import Extension, setup from setuptools.command.build_ext import build_ext +__version__ = "0.23.0.dev0" + class CMakeExtension(Extension): def __init__(self, name, sourcedir=""): @@ -67,6 +68,8 @@ def build_extension(self, ext): "-DCMAKE_CUDA_COMPILER=nvcc", ] + # Append additional CMake arguments from the environment variable. + # This is e.g. used by cibuildwheel to force a certain C++ standard. additional_cmake_args = os.environ.get("CMAKE_ARGS", "") if additional_cmake_args: cmake_args += additional_cmake_args.split() @@ -110,9 +113,7 @@ def build_extension(self, ext): env = os.environ.copy() cxxflags = env.get("CXXFLAGS", "") - env["CXXFLAGS"] = ( - f'{cxxflags} -DVERSION_INFO=\\"{self.distribution.get_version()}\\"' - ) + env["CXXFLAGS"] = f'{cxxflags} -DVERSION_INFO=\\"{__version__}\\"' if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) subprocess.check_call( @@ -124,42 +125,7 @@ def build_extension(self, ext): ) -with open("requirements.txt") as f: - requirements = [ - line.strip() for line in f if line.strip() and not line.strip().startswith("#") - ] -with open("dev-requirements.txt") as f: - dev_requirements = [ - line.strip() for line in f if line.strip() and not line.strip().startswith("#") - ] - -description = "Schrödinger and Schrödinger-Feynman simulators for quantum circuits." - -# README file as long_description. -with open("README.md", encoding="utf-8") as f: - long_description = f.read() - -__version__ = runpy.run_path("qsimcirq/_version.py")["__version__"] -if not __version__: - raise ValueError("Version string cannot be empty") - setup( - name="qsimcirq", - version=__version__, - url="https://github.com/quantumlib/qsim", - author="The qsim/qsimh Developers", - author_email="qsim-qsimh-dev@googlegroups.com", - maintainer="Google Quantum AI", - maintainer_email="quantum-oss-maintainers@google.com", - python_requires=">=3.10.0", - install_requires=requirements, - extras_require={ - "dev": dev_requirements, - }, - license="Apache-2.0", - description=description, - long_description=long_description, - long_description_content_type="text/markdown", ext_modules=[ CMakeExtension("qsimcirq/qsim_avx512"), CMakeExtension("qsimcirq/qsim_avx2"), @@ -170,49 +136,5 @@ def build_extension(self, ext): CMakeExtension("qsimcirq/qsim_decide"), CMakeExtension("qsimcirq/qsim_hip"), ], - cmdclass=dict(build_ext=CMakeBuild), - zip_safe=False, - packages=["qsimcirq"], - package_data={"qsimcirq": ["py.typed"]}, - 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", - "api", - "application programming interface", - "cirq", - "google quantum", - "google", - "nisq", - "python", - "quantum algorithm development", - "quantum circuit simulator", - "quantum computer simulator", - "quantum computing", - "quantum computing research", - "quantum programming", - "quantum simulation", - "quantum", - "schrödinger-feynman simulation", - "sdk", - "simulation", - "state vector simulator", - "software development kit", - ], + cmdclass={"build_ext": CMakeBuild}, )