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

Implement PEP 639 #4829

Merged
merged 56 commits into from
Mar 19, 2025
Merged

Implement PEP 639 #4829

merged 56 commits into from
Mar 19, 2025

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Feb 17, 2025

Summary of changes

This PR is a "mega PR" that simply make sure all the steps to implement PEP 639 are added at the same time to the main branch.
This is done to avoid problems with incomplete changes:

  • We know that tools are being designed and implement PEP 639 compatibility
  • We know existing tools know how to understand the current implementation in setuptools
  • We don't know how tools would react to something that is not quite a PEP 639 implementation or the exact existing implementation in setuptools.

All the PR are previous reviewed individually.

Good to have according to #4829 (comment):

  • The PEP specifies that tools should reject any patterns which contain not-approved chars.
  • Furthermore, it should be an error if a pattern doesn't match any files.
  • Tools should also validate that the license files themselves are utf-8 encoded. Although I don't think that's a priority tbh.
  • Currently missing but not blocking
  • Lastly, we should probably provide some kind of transition path from tool.setuptools.license-files to project.license-files. Be it as simple as rejecting both together (in which case tool.setuptools.license-files is used) or emitting a warning that tool.setuptools.license-files is deprecated in favor of project.license-files.

Compatibility with other peps:

NOTE: I believe that we can simply fast forward the Core Metadata to 2.4 considering that:

https://github.com/pypa/setuptools/blob/v75.8.0/setuptools/_core_metadata.py#L236-L250

Closes

Pull Request Checklist

Footnotes

  1. Currently there is a problem with packaging implementation https://github.com/pypa/packaging/issues/845, but for the sake of advancing the setuptools implementation to catch up with the standards we can consider this a "well known bug" that would be solved in the context of pypa/packaging.

Sorry, something went wrong.

cdce8p and others added 12 commits January 28, 2025 10:56

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Update validate-pyproject to 0.23.0

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@cdce8p
Copy link
Contributor

cdce8p commented Feb 17, 2025

Opened #4830 with the metadata version bump. I can rebase it after #4706 is merged into the feature branch.

@abravalheri
Copy link
Contributor Author

Thank you very much @cdce8p!

It seems that a new error with installing tox on cygwin appeared on the CI. I will try to check if it exists in the main branch as it is probably unrelated.

cdce8p and others added 8 commits February 17, 2025 16:42

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@cdce8p
Copy link
Contributor

cdce8p commented Feb 17, 2025

One area in which the implementation could still be improved is probably the license-files handling. https://peps.python.org/pep-0639/#add-license-files-key

  • The PEP specifies that tools should reject any patterns which contain not-approved chars.
  • Furthermore, it should be an error if a pattern doesn't match any files.
  • Tools should also validate that the license files themselves are utf-8 encoded. Although I don't think that's a priority tbh.
  • Lastly, we should probably provide some kind of transition path from tool.setuptools.license-files to project.license-files. Be it as simple as rejecting both together (in which case tool.setuptools.license-files is used) or emitting a warning that tool.setuptools.license-files is deprecated in favor of project.license-files.

There is also the matter of setup.py and setup.cfg files. My initial intent was to require pyproject.toml for PEP 639. However I haven't tested what happens if one of the setup files overwrites the project metadata.

Side note: Adding support for license expressions to setup.py or setup.cfg is probably a lost cause in itself, as these use a license key already.

--
This looks like a larger list than it is. In particular, they are mostly quality-of-life improvements. So I wouldn't consider them a necessity for the initial implementation.

@abravalheri
Copy link
Contributor Author

abravalheri commented Feb 17, 2025

Thank you for the review @cdce8p.

Let's make a checkbox:

  • The PEP specifies that tools should reject any patterns which contain not-approved chars.
  • Furthermore, it should be an error if a pattern doesn't match any files.
  • Tools should also validate that the license files themselves are utf-8 encoded. Although I don't think that's a priority tbh.
  • Lastly, we should probably provide some kind of transition path from tool.setuptools.license-files to project.license-files. Be it as simple as rejecting both together (in which case tool.setuptools.license-files is used) or emitting a warning that tool.setuptools.license-files is deprecated in favor of project.license-files.

I would like to tackle at least the last of this points before releasing because we can introduce all the related deprecation warnings/breaking errors at once.

Side note: Adding support for license expressions to setup.py or setup.cfg is probably a lost cause in itself, as these use a license key already.

I agree that there is not much point on updating setup.cfg or setup.py support... although it might be the case if someone sets license_expression = ... there it will just work (remains untested).

Sorry, something went wrong.

abravalheri and others added 12 commits February 20, 2025 10:36

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…ect.toml`) with `license`/`license_expression`/`license_files` (#4842)
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
@abravalheri
Copy link
Contributor Author

This week we had some friction with a different feature that was "queued for release", and next week I will not be around to help with the release/fixing reports from users. So the earliest we could do is in the week after the next one.

@cdce8p
Copy link
Contributor

cdce8p commented Feb 27, 2025

next week I will not be around to help with the release/fixing reports from users. So the earliest we could do is in the week after the next one.

I could help out if I see something. Tbh I think the risk here is fairly well contained. As long as we don't break existing configs which this branch shouldn't do, we're likely safe. Anything else which doesn't work 100% could be fixed afterwards as well, once there is more time.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@abravalheri abravalheri marked this pull request as ready for review March 11, 2025 10:37
@abravalheri
Copy link
Contributor Author

@jaraco, would be OK if I create a release merging this implementation some time tomorrow? Or should I wait time more until we stabilise the change in distutils.compilers?

I would like to cut a release including this PR (#4829) + #4870 + #4869

(The cygwin error in the CI is already fixed on main)

@abravalheri
Copy link
Contributor Author

OK, there has been a couple of other releases this week.
So it might be prudent to wait another one.

@jaraco
Copy link
Member

jaraco commented Mar 12, 2025 via email

@abravalheri
Copy link
Contributor Author

I plan to work on this release this week (hopefully tomorrow).

I understand that there is still some sort of instability due to recent distutils changes (e.g. #4885), but hopefully they affect a small portion of the userbase (¿?) ... and we have been holding back for a while.

@abravalheri abravalheri merged commit fb161a2 into main Mar 19, 2025
39 of 44 checks passed
@abravalheri abravalheri deleted the feature/pep639 branch March 19, 2025 16:51
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.

None yet

3 participants