Skip to content
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

PEP 621: Migrate from setup.py to pyproject.toml -- Part 2 #246

Closed
wants to merge 1 commit into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Sep 26, 2023

How

Migrate setup.py to setup.cfg using setuptools-py2cfg plus manual modifications. Use setup-cfg-fmt to format the results.

Migrate settings from setup.cfg into pyproject.toml using ini2toml to do the file conversion and running pyproject-fmt and then validate-pyproject in pre-commit to validate the results.

Flake8 still does not support the use pyproject.toml so its configuration was moved to a .flake8 file.

Why

https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use

We recommend users expose as much as possible configuration in a more declarative way via the pyproject.toml or setup.cfg, and keep the setup.py minimal with only the dynamic parts (or even omit it completely if applicable).

From validate-pyproject README:

With the approval of PEP 517 and PEP 518, the Python community shifted towards a strong focus on standardization for packaging software, which allows more freedom when choosing tools during development and make sure packages created using different technologies can interoperate without the need for custom installation procedures.

This shift became even more clear when PEP 621 was also approved, as a standardized way of specifying project metadata and dependencies.

validate-pyproject was born in this context, with the mission of validating pyproject.toml files, and making sure they are compliant with the standards and PEPs.

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e7b9365) 93.83% compared to head (6fb51b0) 93.83%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #246   +/-   ##
=======================================
  Coverage   93.83%   93.83%           
=======================================
  Files          11       11           
  Lines         535      535           
  Branches       87       87           
=======================================
  Hits          502      502           
  Misses         21       21           
  Partials       12       12           

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

Copy link
Contributor

@adamchainz adamchainz left a comment

Choose a reason for hiding this comment

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

The conversion seems mostly good to me. I would push the pre-commit and ruff setup into a separate PR.

One question about the version: the change to dynamic version doesn't seem to use setuptools-scm now? Previously the __init__.py used this pattern from the docs: https://setuptools-scm.readthedocs.io/en/latest/usage/#python-package-metadata . Now you've hardcoded it in the file, which will need updating for each release.

(Personally, I'd remove the __version__ attribute, I think the pattern is no longer necessary now that we have importlib.metadata.version().)

@claudep
Copy link
Contributor

claudep commented Nov 25, 2023

I extracted just the PEP 621 part in #253, any review welcome. Of course, the rest of the patch is also valuable and could be pushed in a separate PR. By the way, I don't think we need both ruff and flake8. ruff only is fine.

@cclauss cclauss mentioned this pull request Nov 26, 2023
@cclauss cclauss force-pushed the pyproject.toml branch 2 times, most recently from b027301 to bc5ec71 Compare November 26, 2023 15:18
@cclauss cclauss changed the title PEP 621: Migrate from setup.py to pyproject.toml PEP 621: Migrate from setup.py to pyproject.toml -- Part 2 Nov 26, 2023
@cclauss
Copy link
Contributor Author

cclauss commented Nov 26, 2023

Closing in favor of #256

@cclauss cclauss closed this Nov 26, 2023
@cclauss cclauss deleted the pyproject.toml branch November 26, 2023 16:22
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