-
-
Notifications
You must be signed in to change notification settings - Fork 339
Respect PEP 621 dynamic fields when merging Cargo.toml metadata #2672
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
Respect PEP 621 dynamic fields when merging Cargo.toml metadata #2672
Conversation
…from Cargo.toml Co-authored-by: messense <1556054+messense@users.noreply.github.com>
…ml metadata - Add logic to only include Cargo.toml metadata fields when explicitly declared as dynamic in pyproject.toml - Update test pyproject.toml files to declare necessary fields as dynamic for backward compatibility - Add comprehensive test cases for both behaviors (with and without dynamic fields) - Manually verified the fix works end-to-end with real wheel builds Co-authored-by: messense <1556054+messense@users.noreply.github.com>
…yproject.toml This maintains compatibility with the existing test expectations while respecting PEP 621 dynamic field requirements. Co-authored-by: messense <1556054+messense@users.noreply.github.com>
@copilot run |
Co-authored-by: messense <1556054+messense@users.noreply.github.com>
@copilot run |
I've run the pre-commit checks. Due to network connectivity issues, I couldn't install all external tools, but I completed the core checks: ✅ The most important formatting and validation checks have been completed successfully. |
@copilot fix |
Co-authored-by: messense <1556054+messense@users.noreply.github.com>
@copilot fix trailing whitespace in |
Co-authored-by: messense <1556054+messense@users.noreply.github.com>
https://build.opensuse.org/request/show/1297806 by user mia + dimstar_suse - Update to 1.9.3 * Add support for RISC-V architecture in manylinux gh#PyO3/maturin#2694 * pyproject.toml: bump setuptools for PEP 639 gh#PyO3/maturin#2698 * Fix PEP 639 support for source distributions gh#PyO3/maturin#2704 * Fix relative README rewrite in source distributions gh#PyO3/maturin#2705 - Update to 1.9.2 * Respect PEP 621 dynamic fields when merging Cargo.toml metadata gh#PyO3/maturin#2672 * Only use all_features=true in sdist when local path dependencies exist gh#PyO3/maturin#2674 * auditwheel: add manylinux_2_26 policy gh#PyO3/maturin#2677 * Use user-specified library search paths in RUSTFLAGS in auditwheel gh#PyO3/maturin#2676 * pyproject.toml: add license-files gh#PyO3/maturin#2690 * Update manylinux/musllinux
Summary
Fixes #2544 by ensuring maturin only includes metadata fields from
Cargo.toml
when they are explicitly declared asdynamic
inpyproject.toml
, in compliance with PEP 621.Problem
Previously, maturin would unconditionally include metadata fields like
description
,authors
,keywords
, andurls
fromCargo.toml
into wheel metadata, even when these fields were not declared in thedynamic
list inpyproject.toml
. This violates PEP 621, which states:Example
Before this fix:
The wheel metadata would incorrectly include:
Summary: Description from Cargo.toml
Author: Author <author@example.com>
Keywords: rust,python
After this fix:
The wheel metadata only includes fields from
pyproject.toml
and respects the dynamic list:Name: my-package
andVersion: 0.1.0
are includedTo include Cargo.toml fields, they must be explicitly declared:
Changes
Metadata24::merge_pyproject_toml()
to clear metadata fields from Cargo.toml that are not declared in thedynamic
listpyproject.toml
files to declare necessary fields as dynamic to maintain existing test behaviorTesting
test_issue_2544_respect_pyproject_dynamic()
to verify fields are excluded when not in dynamic listtest_issue_2544_respect_pyproject_dynamic_with_dynamic_fields()
to verify fields are included when in dynamic listFields Affected
The following metadata fields now respect the dynamic list:
description
→summary
in wheel metadataauthors
→author
andauthor-email
maintainers
→maintainer
andmaintainer-email
keywords
→keywords
urls
→project-url
license
→license
classifiers
→classifiers
readme
→description
anddescription-content-type
requires-python
→requires-python
This ensures full PEP 621 compliance while maintaining backward compatibility for projects that explicitly declare their dynamic fields.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.