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 30 commits into
base: master
Choose a base branch
from
Open

Migrating setup.py to pyproject.toml #7375

wants to merge 30 commits into from

Conversation

runora95
Copy link
Contributor

@runora95 runora95 commented May 2, 2025

Context:
The build and installation methods using setup.py have been deprecated; pyproject.toml is the recommended method. Pennylane needs to be updated to use pyproject.toml instead.

Description of the Change:
Update pyproject.toml to be used to build packages

Benefits:
setup.py is deprecated, this change ensures that packages can still be built

Possible Drawbacks:

Related GitHub Issues:

Copy link
Contributor

github-actions bot commented May 2, 2025

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented May 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.69%. Comparing base (5a28158) to head (f6eedec).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7375   +/-   ##
=======================================
  Coverage   99.69%   99.69%           
=======================================
  Files         529      529           
  Lines       50610    50610           
=======================================
  Hits        50455    50455           
  Misses        155      155           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@runora95 runora95 requested a review from rashidnhm May 7, 2025 16:14
Copy link
Contributor

@rashidnhm rashidnhm left a comment

Choose a reason for hiding this comment

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

Though CI is passing, it seems there are some deprecation warnings being raised by uv, we may want to address those as part of this PR.

https://github.com/PennyLaneAI/pennylane/actions/runs/14887842195/job/41812184792?pr=7375#step:9:17

/home/runner/work/_temp/setup-uv-cache/builds-v0/.tmptnMJ7R/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated
!!

        ********************************************************************************
        Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0).

        By 2026-Feb-[18](https://github.com/PennyLaneAI/pennylane/actions/runs/14887842195/job/41812184792?pr=7375#step:9:19), you need to update your project and remove deprecated calls
        or your builds will no longer be supported.

        See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
        ********************************************************************************

!!
  corresp(dist, value, root_dir)
/home/runner/work/_temp/setup-uv-cache/builds-v0/.tmptnMJ7R/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

        ********************************************************************************
        Please consider removing the following classifiers in favor of a SPDX license expression:

        License :: OSI Approved :: Apache Software License

        See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
        ********************************************************************************

!!
  dist._finalize_license_expression()
/home/runner/work/_temp/setup-uv-cache/builds-v0/.tmptnMJ7R/lib/python3.10/site-packages/setuptools/dist.py:761: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

        ********************************************************************************
        Please consider removing the following classifiers in favor of a SPDX license expression:

        License :: OSI Approved :: Apache Software License

        See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
        ********************************************************************************

!!

@runora95 runora95 requested a review from rashidnhm May 7, 2025 20:53
@runora95 runora95 requested a review from rashidnhm May 8, 2025 19:44
setup.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

The entire content of this file should be:

from setuptools import setup

setup()

Everything in between is not needed

pyproject.toml Outdated
@@ -1,3 +1,83 @@
[build-system]
requires = ["setuptools>=75", "tomli"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
requires = ["setuptools>=75", "tomli"]
requires = ["setuptools>=75.8.1", "tomli"]

setuptools < 75.8.1 may cause build failures, hence why we explicitly pin it explicitly in CI (See #7005)

Also, does PL need tomli as a build dependency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants