diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b404993da..cf787d0da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,7 +84,7 @@ files configure various tools to the project conventions: * `.pylintrc`: Python file lint -* `.pyproject.toml`: Python tools other than Pylint +* `pyproject.toml`: package metadata, dependencies, and Python tool configuration (except Pylint) * `.yamllint.yaml`: YAML files @@ -222,12 +222,22 @@ After that, the hooks will run automatically when triggered by the corresponding pip install -U pip ``` -2. Use the following command to install Python dependencies into the virtual environment: +2. Use one of the following to install Python dependencies into the virtual environment: ```shell pip install -r dev_tools/requirements/envs/dev.env.txt ``` + Or, with [uv](https://docs.astral.sh/uv/) (locked files are still generated from + `dev_tools/requirements/deps/*.txt`; see _Regenerating requirements files_ below): + + ```shell + uv sync --group dev + ``` + + Package metadata and runtime dependencies are defined in `pyproject.toml` (there is no + `setup.py`). + Please refer to the section _Developer install_ of the [installation instructions](docs/install.md) for information about how to set up a local copy of the software for development. diff --git a/MANIFEST.in b/MANIFEST.in index f02ee6f06..70217142b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,7 @@ include LICENSE include MANIFEST.in include NOTICE include README.md +include pyproject.toml include dev_tools/requirements/deps/runtime.txt include dev_tools/requirements/deps/resource_estimates_runtime.txt -include setup.py recursive-include src *.py *.hdf5 *.h5 bad_type_operator.data geometry_example.txt diff --git a/dev_tools/packaging/produce-package.sh b/dev_tools/packaging/produce-package.sh index 8ea4a20c6..134fe07c6 100755 --- a/dev_tools/packaging/produce-package.sh +++ b/dev_tools/packaging/produce-package.sh @@ -29,6 +29,7 @@ # this, stricter requirements for versioning were introduced. This means that # the "version" argument to this script must conform to patterns described at # https://packaging.python.org/en/latest/discussions/versioning/. +# Project metadata and dependencies are defined in pyproject.toml. ################################################################################ PROJECT_NAME=openfermion @@ -64,7 +65,7 @@ function confirm() { } # Make a clean copy of HEAD, without files ignored by git (but potentially kept -# by setup.py). +# locally). if [ -n "$(git status --short)" ]; then echo -e "${RED}WARNING: There are uncommitted git changes." echo -e "They won't be included in the package.${RESET}" diff --git a/pyproject.toml b/pyproject.toml index 84b383687..7ad7e6875 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright 2025 Google LLC +# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,6 +12,154 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Note: there are three types of dependencies listed in this file: +# +# [build-system].requires: packages needed by the build backend. Not stored in +# package metadata. +# +# [project].dependencies: core runtime packages (install_requires). Stored in +# package metadata and installed with `pip install openfermion`. +# +# [dependency-groups].dev: development tools for tests, linters, and packaging. +# Install with `uv sync --group dev` or `pip install --group dev` (PEP 735). +# Locked CI environments are still generated under dev_tools/requirements/envs/ +# via dev_tools/requirements/create-env-files.sh. + +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=78.1.1", "wheel"] + +[project] +name = "openfermion" +description = "The electronic structure package for quantum computers." +readme = {file = "README.md", content-type = "text/markdown"} +license = "Apache-2.0" +authors = [ + {name = "The OpenFermion Developers", email = "openfermion-dev@googlegroups.com"}, +] +maintainers = [ + {name = "Google Quantum AI open-source maintainers", email = "quantum-oss-maintainers@google.com"}, +] +requires-python = ">=3.10.0" +dynamic = ["version", "dependencies", "optional-dependencies"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "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 :: Chemistry", + "Topic :: Scientific/Engineering :: Quantum Computing", +] +keywords = [ + "algorithms", + "api", + "application programming interface", + "chemistry", + "cirq", + "electronic structure", + "fermion", + "fermionic systems", + "google quantum", + "google", + "hamiltonians", + "high performance", + "nisq", + "noisy intermediate-scale quantum", + "python", + "quantum algorithms", + "quantum chemistry", + "quantum circuit simulator", + "quantum circuit", + "quantum computer simulator", + "quantum computing", + "quantum development kit", + "quantum programming language", + "quantum programming", + "quantum simulation", + "quantum", + "qubit hamiltonians", + "qubit", + "sdk", + "simulation", + "software development kit", +] + +[project.urls] +Homepage = "https://quantumai.google/openfermion" +Documentation = "https://quantumai.google/openfermion" +Source = "https://github.com/quantumlib/OpenFermion" + +[dependency-groups] +# Development dependencies. Keep in sync with dev_tools/requirements/deps/*.txt. +dev = [ + # Formatting and linting. + "black", + "mypy", + "pandas-stubs", + "pylint~=3.3", + "types-networkx", + "types-requests", + "types-setuptools", + + # Testing. + "nbformat", + "pytest", + "pytest-asyncio", + "pytest-cov", + "pytest-randomly", + "pytest-retry", + "pytest-xdist", + "tensorflow-docs", + + # Resource-estimate runtime deps (see resource_estimates_runtime.txt). + "ase", + "jax", + "jaxlib", + "pyscf", + + # Packaging and requirements regeneration. + "build", + "setuptools", + "shellcheck-py~=0.11.0", + "twine", + "uv", + "virtualenv", + "wheel", +] + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-dir] +"" = "src" + +[tool.setuptools.package-data] +openfermion = [ + "resource_estimates/integrals/*.h5", + "testing/*.npy", + "testing/*.hdf5", + "testing/*.data", + "testing/*.txt", +] + +[tool.setuptools.dynamic] +version = {attr = "openfermion._version.__version__"} +dependencies = {file = ["dev_tools/requirements/deps/runtime.txt"]} + +[tool.setuptools.dynamic.optional-dependencies] +resources = {file = ["dev_tools/requirements/deps/resource_estimates_runtime.txt"]} + [tool.black] line-length = 100 target-version = ['py310', 'py311', 'py312', 'py313'] diff --git a/setup.py b/setup.py deleted file mode 100755 index 27ff1aeac..000000000 --- a/setup.py +++ /dev/null @@ -1,113 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import runpy - -from setuptools import find_packages, setup - -# This reads the __version__ variable from openfermion/_version.py -__version__ = runpy.run_path('src/openfermion/_version.py')['__version__'] -assert __version__, 'Version string cannot be empty' - -# The readme file is used as the long_description: -long_description = '===========\n' + 'OpenFermion\n' + '===========\n\n' -with open('README.md', 'r', encoding='utf-8') as readme: - long_description += readme.read() - -# Read in package requirements.txt. -with open('dev_tools/requirements/deps/runtime.txt') as r: - requirements = r.readlines() -requirements = [r.strip() for r in requirements] -requirements = [r for r in requirements if not r.startswith('#')] - -# Read in resource estimates requirements. -with open('dev_tools/requirements/deps/resource_estimates_runtime.txt') as r: - resource_requirements = r.readlines() -resource_requirements = [r.strip() for r in resource_requirements] -resource_requirements = [r for r in resource_requirements if not r.startswith('#')] - -setup( - name='openfermion', - version=__version__, - url='https://quantumai.google/openfermion', - license='Apache-2.0', - author='The OpenFermion Developers', - author_email='openfermion-dev@googlegroups.com', - maintainer='Google Quantum AI open-source maintainers', - maintainer_email='quantum-oss-maintainers@google.com', - description=('The electronic structure package for quantum computers.'), - long_description=long_description, - python_requires='>=3.10.0', - install_requires=requirements, - extras_require={'resources': resource_requirements}, - packages=find_packages(where='src'), - package_dir={'': 'src'}, - include_package_data=True, - package_data={ - '': [ - os.path.join('src', 'openfermion', 'resource_estimates', 'integrals', '*.h5'), - os.path.join('src', 'openfermion', 'testing', '*.npy'), - os.path.join('src', 'openfermion', 'testing', '*.hdf5'), - ] - }, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: MacOS', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX :: Linux', - '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 :: Chemistry', - 'Topic :: Scientific/Engineering :: Quantum Computing', - ], - keywords=[ - 'algorithms', - 'api', - 'application programming interface', - 'chemistry', - 'cirq', - 'electronic structure', - 'fermion', - 'fermionic systems', - 'google quantum', - 'google', - 'hamiltonians', - 'high performance', - 'nisq', - 'noisy intermediate-scale quantum', - 'python', - 'quantum algorithms', - 'quantum chemistry', - 'quantum circuit simulator', - 'quantum circuit', - 'quantum computer simulator', - 'quantum computing', - 'quantum development kit', - 'quantum programming language', - 'quantum programming', - 'quantum simulation', - 'quantum', - 'qubit hamiltonians', - 'qubit', - 'sdk', - 'simulation', - 'software development kit', - ], -) diff --git a/src/openfermion/_version.py b/src/openfermion/_version.py index 3d788ba1e..5bfef6eb6 100644 --- a/src/openfermion/_version.py +++ b/src/openfermion/_version.py @@ -10,6 +10,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Define version number here and read it from setup.py automatically""" +"""Define version number here; read by setuptools from pyproject.toml.""" __version__ = "1.7.2.dev0"