Skip to content

Migrating setup.py to pyproject.toml #7375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dc3a72f
Migrating setup.py to pyproject.toml
runora95 May 2, 2025
082b21c
Merge branch 'master' into set-pyproj
runora95 May 2, 2025
97c48c5
fixed typo
runora95 May 2, 2025
c18d0ee
Adding numpy to toml
runora95 May 2, 2025
aa722ae
removing numpy
runora95 May 2, 2025
c1c4e24
updated pyproj
runora95 May 5, 2025
0c67ce2
Merge branch 'master' into set-pyproj
runora95 May 5, 2025
be86236
removed packages find
runora95 May 5, 2025
02f2790
Trigger Build
runora95 May 5, 2025
e099c96
removed setup.py
runora95 May 6, 2025
ce34142
added tools dynamic
runora95 May 6, 2025
59a0df4
Trigger Build
runora95 May 6, 2025
e1fda00
setup.py
runora95 May 6, 2025
fc3a1c2
Merge branch 'master' into set-pyproj
runora95 May 6, 2025
f6326a5
update dockerfile
runora95 May 6, 2025
616de65
remove setup.py
runora95 May 6, 2025
668bcf9
Merge branch 'master' into set-pyproj
runora95 May 7, 2025
58eab8e
Moving setup.py to bacup file
runora95 May 7, 2025
6330f0d
changing to setup-dev
runora95 May 7, 2025
adf55ea
changed setup.py
runora95 May 7, 2025
e646c88
Moved license in toml
runora95 May 7, 2025
d1f8dee
Merge branch 'master' into set-pyproj
runora95 May 7, 2025
afb7914
fixed licence in classifiers
runora95 May 7, 2025
3c17400
updated changelog-dev
runora95 May 7, 2025
bccd638
Update doc/releases/changelog-dev.md
runora95 May 8, 2025
53cf7ba
removing cmake
runora95 May 8, 2025
ff431ab
Merge branch 'master' into set-pyproj
runora95 May 8, 2025
61406ed
clearing setup.py
runora95 May 8, 2025
057539f
updating requires
runora95 May 8, 2025
f6eedec
Merge branch 'master' into set-pyproj
runora95 May 8, 2025
432a0c6
Merge branch 'master' into set-pyproj
runora95 May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. `<demos/>` or `<catalyst/>` 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. `<demos/>` or `<catalyst/>` 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)

Expand Down
2 changes: 1 addition & 1 deletion docker/interfaces/gpu-cuda/cuda-base.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker/pennylane.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"

[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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setup.py had a TODO message on the entry points, let's keep it here as well

"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?$'
Expand Down
91 changes: 1 addition & 90 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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()