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

Update to Metadata 2.3 to create reliable source dist metadata #1965

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

konstin
Copy link
Member

@konstin konstin commented Feb 27, 2024

Source distributions contain a PKG-INFO file at root level with metadata in the same format as wheel metadata. Unlike wheel metadata, this file was previously unreliably, the metadata did not need to (and often did not) match the metadata of the built wheel.

PEP 643 introduces Metadata 2.2, where fields can either be static (default) or marked as dynamic. When a source distribution uses Metadata-Version: 2.3 in its PKG-INFO file, all static fields in the source distribution metadata must match the metadata of a built wheel (spec). This means that e.g. when requirements and extras are not marked as dynamic, a version resolver can read the metadata directly from the source dist without a PEP 517 invocation. This is both a huge speedup and makes python packaging more reliable.

This PR bumps the metadata version maturin uses to 2.3 (PEP 685 – Comparison of extra names for optional distribution dependencies). It does not add support for dynamic, instead maturin writes static metadata for all of its source dists. If possible, i'd like to keep maturin to emit purely static metadata, it has advantages both for the python packaging ecosystem and by enforcing a better project structure. If you want a single source of truth for the package version, i recommend storing the version in pyproject.toml project.version and using importlib.metadata.version in the python code.

I bump the version to 1.5.0 since it's a significant behaviour change, but doesn't justify a 2.0 release.

@konstin konstin added the enhancement New feature or request label Feb 27, 2024
Copy link

netlify bot commented Feb 27, 2024

Deploy Preview for maturin-guide ready!

Name Link
🔨 Latest commit 9d26d20
🔍 Latest deploy log https://app.netlify.com/sites/maturin-guide/deploys/65e5e2333455390008f4592c
😎 Deploy Preview https://deploy-preview-1965--maturin-guide.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

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

LGTM.

I suppose pypi/warehouse#13606 has already been deployed to pypi production?

@konstin
Copy link
Member Author

konstin commented Feb 27, 2024

@konstin
Copy link
Member Author

konstin commented Feb 27, 2024

Twine issue for the ci failure: pypa/twine#1059

Source distributions contain a `PKG-INFO` file at root level with metadata in the same format as wheel metadata. Unlike wheel metadata, this file was previously unreliably, the metadata did not need to (and often did not) match the metadata of the built wheel.

[PEP 643](https://peps.python.org/pep-0643/) introduces Metadata 2.2, where fields can either be static (default) or marked as dynamic. When a source distribution uses `Metadata-Version: 2.3` in its PKG-INFO file, all static fields in the source distribution metadata must match the metadata of a built wheel ([spec](https://packaging.python.org/en/latest/specifications/source-distribution-format/#source-distribution-format)). This means that e.g. when requirements and extras are not marked as dynamic, a version resolver can read the metadata directly from the source dist without a PEP 517 invocation. This is both a huge speedup and makes python packaging more reliable.

This PR bumps the metadata version maturin uses to 2.3 ([PEP 685](https://peps.python.org/pep-0685/) – Comparison of extra names for optional distribution dependencies). It does not add support for dynamic, instead maturin writes static metadata for all of its source dists. If possible, i'd like to keep maturin to emit purely static metadata, it has advantages both for the python packaging ecosystem and by enforcing a better project structure. If you want a single source of truth for the package version, i recommend storing the version in pyproject.toml `project.version` and using `importlib.metadata.version` in the python code.

I bump the version to 1.5.0 since it's a significant behaviour change, but doesn't justify a 2.0 release.
@konstin konstin added this pull request to the merge queue Mar 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2024
@konstin konstin added this pull request to the merge queue Mar 4, 2024
Merged via the queue into main with commit 7bd229d Mar 4, 2024
29 checks passed
@konstin konstin deleted the konsti/metadata-2-3 branch March 4, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants