diff --git a/.github/workflows/tests-gpu.yml b/.github/workflows/tests-gpu.yml index 4c82fdbf39c..058bf381ecb 100644 --- a/.github/workflows/tests-gpu.yml +++ b/.github/workflows/tests-gpu.yml @@ -102,7 +102,7 @@ jobs: - name: Install PennyLane run: | - python setup.py bdist_wheel + python -m build --wheel pip install dist/pennylane*.whl - name: Install Lightning-master diff --git a/Makefile b/Makefile index 8b3bec9be42..ca508c85ed6 100644 --- a/Makefile +++ b/Makefile @@ -25,15 +25,15 @@ install: ifndef PYTHON3 @echo "To install PennyLane you need to have Python 3 installed" endif - $(PYTHON) setup.py install + $(PYTHON) -m pip install . .PHONY: wheel wheel: - $(PYTHON) setup.py bdist_wheel + $(PYTHON) -m build --wheel .PHONY: dist dist: - $(PYTHON) setup.py sdist + $(PYTHON) -m build --sdist .PHONY : clean clean: diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 92ca0887554..39dea3881ec 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -180,9 +180,12 @@ interface to maintain a list of special implementations. [(#7327)](https://github.com/PennyLaneAI/pennylane/pull/7327) -* Sphinx version was updated to 8.1. Sphinx is upgraded to version 8.1 and uses Python 3.10. References to intersphinx (e.g. `` or `` are updated to remove the :doc: prefix that is incompatible with sphinx 8.1. +* Sphinx version was updated to 8.1. Sphinx is upgraded to version 8.1 and uses Python 3.10. References to intersphinx (e.g. `` or `` are updated to remove the :doc: prefix that is incompatible with sphinx 8.1. [(7212)](https://github.com/PennyLaneAI/pennylane/pull/7212) +* Migrated `setup.py` package build and install to `pyproject.toml` + [(#7375)](https://github.com/PennyLaneAI/pennylane/pull/7375) + * Updated GitHub Actions workflows (`rtd.yml`, `readthedocs.yml`, and `docs.yml`) to use `ubuntu-24.04` runners. [(#7396)](https://github.com/PennyLaneAI/pennylane/pull/7396) diff --git a/docker/interfaces/gpu-cuda/cuda-base.dockerfile b/docker/interfaces/gpu-cuda/cuda-base.dockerfile index 1c9ac554560..04d8b7d121f 100644 --- a/docker/interfaces/gpu-cuda/cuda-base.dockerfile +++ b/docker/interfaces/gpu-cuda/cuda-base.dockerfile @@ -42,7 +42,7 @@ COPY . . RUN git submodule update --init --recursive \ && pip install wheel \ && pip install -r requirements.txt \ - && python3 setup.py install \ + && python3 -m pip install . \ && pip install -r requirements-dev.txt \ && make test diff --git a/docker/pennylane.dockerfile b/docker/pennylane.dockerfile index cbb7f40f0a4..80e562a5664 100644 --- a/docker/pennylane.dockerfile +++ b/docker/pennylane.dockerfile @@ -41,7 +41,7 @@ WORKDIR /opt/pennylane COPY . . RUN git submodule update --init --recursive RUN pip install wheel && pip install -r requirements.txt -RUN python3 setup.py install +RUN python3 -m pip install . RUN pip install -r requirements-dev.txt RUN pip install -i https://test.pypi.org/simple/ pennylane-lightning --pre --upgrade # hotfix, remove when pyscf 2.1 is released (currently no wheel for python3.10) diff --git a/pyproject.toml b/pyproject.toml index 8f25644083c..3945ccca81b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,83 @@ +[build-system] +requires = ["setuptools>=75.8.1"] +build-backend = "setuptools.build_meta" + +[project] +name = "Pennylane" +description = "PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network." +readme = "README.md" +license = "Apache-2.0" +requires-python = ">=3.10" +dynamic = ["version"] +dependencies = [ + "scipy", + "networkx", + "rustworkx>=0.14.0", + "autograd", + "appdirs", + "autoray>=0.6.11", + "cachetools", + "pennylane-lightning>=0.41", + "requests", + "tomli", + "typing_extensions", + "packaging", + "diastatic-malt", + "numpy" +] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Operating System :: POSIX", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering :: Physics", +] +[[project.maintainers]] +name = "Xanadu Quantum Technologies Inc." +email = "software@xanadu.ai" + +[project.urls] +repository = "https://github.com/PennyLaneAI/pennylane" + +[project.optional-dependencies] +kernels = ["cvxpy", "cvxopt"] + +[project.scripts] +pl-device-test = "pennylane.devices.tests:cli" + +[project.entry-points."pennylane.plugins"] +"default.qubit" = "pennylane.devices:DefaultQubit" +"default.gaussian" = "pennylane.devices:DefaultGaussian" +"default.mixed" = "pennylane.devices.default_mixed:DefaultMixed" +"reference.qubit" = "pennylane.devices.reference_qubit:ReferenceQubit" +"null.qubit" = "pennylane.devices.null_qubit:NullQubit" +"default.qutrit" = "pennylane.devices.default_qutrit:DefaultQutrit" +"default.clifford" = "pennylane.devices.default_clifford:DefaultClifford" +"default.qutrit.mixed" = "pennylane.devices.default_qutrit_mixed:DefaultQutritMixed" +"default.tensor" = "pennylane.devices.default_tensor:DefaultTensor" + +[tool.setuptools] +include-package-data = true +py-modules = [] + +[tool.setuptools.dynamic] +version = {attr = "pennylane._version.__version__"} + +[tool.setuptools_scm] + +[tool.setuptools.package-data] +pennylane = ["devices/tests/pytest.ini", "drawer/plot.mplstyle"] + [tool.black] line-length = 100 include = '\.pyi?$' diff --git a/setup.py b/setup.py index 1595dbc121a..3e1cbcd3f74 100644 --- a/setup.py +++ b/setup.py @@ -1,92 +1,3 @@ -# Copyright 2018-2024 Xanadu Quantum Technologies Inc. - -# 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. - -"""Setup file for package installation.""" -# pylint: disable=unspecified-encoding, consider-using-with - from setuptools import find_packages, setup -with open("pennylane/_version.py") as f: - version = f.readlines()[-1].split()[-1].strip("\"'") - -requirements = [ - "numpy", - "scipy", - "networkx", - "rustworkx>=0.14.0", - "autograd", - "tomlkit", - "appdirs", - "autoray>=0.6.11", - "cachetools", - "pennylane-lightning>=0.41", - "requests", - "typing_extensions", - "packaging", - "diastatic-malt", -] - -info = { - "name": "PennyLane", - "version": version, - "maintainer": "Xanadu Inc.", - "maintainer_email": "software@xanadu.ai", - "url": "https://github.com/PennyLaneAI/pennylane", - "license": "Apache License 2.0", - "packages": find_packages(where="."), - "entry_points": { - # TODO: rename entry point 'pennylane.plugins' to 'pennylane.devices'. - # This requires a rename in the setup file of all devices, and is best done during another refactor - "pennylane.plugins": [ - "default.qubit = pennylane.devices:DefaultQubit", - "default.gaussian = pennylane.devices:DefaultGaussian", - "default.mixed = pennylane.devices.default_mixed:DefaultMixed", - "reference.qubit = pennylane.devices.reference_qubit:ReferenceQubit", - "null.qubit = pennylane.devices.null_qubit:NullQubit", - "default.qutrit = pennylane.devices.default_qutrit:DefaultQutrit", - "default.clifford = pennylane.devices.default_clifford:DefaultClifford", - "default.qutrit.mixed = pennylane.devices.default_qutrit_mixed:DefaultQutritMixed", - "default.tensor = pennylane.devices.default_tensor:DefaultTensor", - ], - "console_scripts": ["pl-device-test=pennylane.devices.tests:cli"], - }, - "description": "PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.", - "long_description": open("README.md").read(), - "long_description_content_type": "text/markdown", - "provides": ["pennylane"], - "install_requires": requirements, - "extras_require": {"kernels": ["cvxpy", "cvxopt"]}, - "package_data": {"pennylane": ["devices/tests/pytest.ini", "drawer/plot.mplstyle"]}, - "include_package_data": True, -} - -classifiers = [ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Science/Research", - "Natural Language :: English", - "Operating System :: POSIX", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3 :: Only", - "Topic :: Scientific/Engineering :: Physics", -] - -setup(classifiers=classifiers, **(info)) +setup()