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

Switch to packaging for parsing metadata and support metadata 2.4 #1180

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dnicolodi
Copy link

@dnicolodi dnicolodi commented Nov 22, 2024

The packaging package is maintained by the PyPA and it is the de-facto reference implementation for the packaging standards. Using packaging for parsing metadata guarantees support for the latest metadata versions.

warehouse, the Python package index implementation used by PyPI, also uses packaging for parsing metadata. This guarantees that metadata parsing is the same on the client and server side, for the most prominent index.

@dnicolodi

This comment was marked as outdated.

@dnicolodi dnicolodi force-pushed the packaging branch 3 times, most recently from 60ba024 to adc9f2e Compare November 24, 2024 01:02
@dnicolodi

This comment was marked as resolved.

@dnicolodi dnicolodi force-pushed the packaging branch 3 times, most recently from 3bc839b to d727449 Compare November 25, 2024 23:21
@dnicolodi dnicolodi changed the title Switch from pkginfo to packaging for parsing distribution metadata Switch to packaging for parsing metadata and support metadata 2.4 Nov 25, 2024
@dnicolodi
Copy link
Author

I've reviewed what warehouse expects in the form data and verified that the code here sends the right thing. This should be complete now. Can someone take a look to check that I did not miss anything? Having the CI jobs running on this PR would also be nice. Thanks!

I could imagine adding some more metadata validation on top, similar to what warehouse does, but it would require adding some dependencies.

The packaging package is maintained by the PyPA and it is the de-facto
reference implementation for the packaging standards. Using packaging
for parsing metadata guarantees support for the latest metadata
versions.

warehouse, the Python package index implementation used by PyPI, also
uses packaging for parsing metadata. This guarantees that metadata
parsing is the same on the client and server side, for the most
prominent index.
It was done in the support code for the wheel file format but it
affects metadata loading from all supported distribution types. Move
it to generic code.
When any of the glob patterns specified in the provisional field
"license-files" in the "tool.setuptools" section in pyproject.toml
matches a file in the package, Setuptools emits a License-File
metadata entry. However, Setuptools sets the Metadata-Version to 2.1.

With the implementation of PEP 639 and metadata version 2.4, this
combination is now invalid and is rejected by packaging, and thus by
PyPI.

Reset tools.setuptools.license-files to do not match any file. This
prevents invalid metadata to be generated.
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.

1 participant