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

Use Metadata 2.2+ for source distributions #2009

Closed
konstin opened this issue Feb 27, 2024 · 3 comments · Fixed by #2293
Closed

Use Metadata 2.2+ for source distributions #2009

konstin opened this issue Feb 27, 2024 · 3 comments · Fixed by #2293
Assignees
Labels
enhancement New feature or improvement to existing functionality good first issue Good for newcomers

Comments

@konstin
Copy link
Member

konstin commented Feb 27, 2024

When a source distribution contains a PKG-INFO file at the top level with Metadata-Version: 2.2 or Metadata-Version: 2.3 and neither Dynamic: Requires-Dist nor Dynamic: Provides-Extra, we can use the information in PKG-INFO as reliable metadata without calling any PEP 517 hooks or even setting up the build env. While the PEP has been accepted for some time, this is now supported by at pypi (pypi/warehouse#13606).

After downloading and unpacking1, we can read PKG-INFO with the same utils as METADATA and given the preconditions perform no build in uv pip compile. This should provide a significant speedup as more package are published with metadata 2.2+.

pyo3-mixed 2.1.5

Footnotes

  1. I don't think .tar.gz has a central directory we could use for the same remote partial reading trick as for zips, but i can't find a good source.

@konstin konstin added the enhancement New feature or improvement to existing functionality label Feb 27, 2024
@charliermarsh
Copy link
Member

Yes!!!

@sbidoul
Copy link

sbidoul commented Feb 27, 2024

Note Version can be dynamic too.

Update: no sorry, version can be dynamic in pyproject.toml (PEP 621). but not in PKG-INFO 2.2+. PEP 643 says "The fields Name and Version MUST NOT be marked as Dynamic."

@charliermarsh charliermarsh added the good first issue Good for newcomers label Mar 7, 2024
@charliermarsh
Copy link
Member

I might do this because it looks fun.

@charliermarsh charliermarsh self-assigned this Mar 8, 2024
charliermarsh added a commit that referenced this issue Mar 8, 2024
## Summary

PyPI now supports Metadata 2.2, which means distributions with Metadata
2.2-compliant metadata will start to appear. The upside is that if a
source distribution includes a `PKG-INFO` file with (1) a metadata
version of 2.2 or greater, and (2) no dynamic fields (at least, of the
fields we rely on), we can read the metadata from the `PKG-INFO` file
directly rather than running _any_ of the PEP 517 build hooks.

Closes #2009.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement to existing functionality good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants