Repository navigation
Put all License-File entries at the sdist root - #3331
Merged
messense merged 1 commit intoOct 22, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation addresses the reported layouts with regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Ensures every License-File entry in sdist metadata exists relative to the archive root, addressing missing licenses in workspace-member and subdirectory layouts.
Changes:
- Copies recorded license files to their metadata paths, preserving existing files and warning on content conflicts.
- Adds source-path lookup support to the virtual writer.
- Adds regression coverage for both affected layouts.
| File | Description |
|---|---|
| tests/run/sdist.rs | Checks license metadata paths against archive contents in both layouts. |
| src/source_distribution/mod.rs | Adds the license-copy pass before writing PKG-INFO. |
| src/module_writer/virtual_writer.rs | Exposes tracked source paths for conflict checks. |
Review effort: Balanced
This comment was marked as resolved.
This comment was marked as resolved.
`License-File` paths in `PKG-INFO` are relative to the sdist root, but only explicit `project.license-files` were copied there. Auto-discovered license files (no `license-files`, or `license-files` in `project.dynamic`) and Cargo's `license-file` were only packaged next to their crate. When `pyproject.toml` is moved to the sdist root above the crate, e.g. for a cargo workspace member, or when the crate lives in a subdirectory via `manifest-path`, the listed paths did not exist in the sdist. PyPI rejects such uploads (`pyo3-introspection` 0.30.0 hit this), and for auto-discovered license files a wheel built from the sdist silently lost them too. After the other sdist files are added, copy every entry of `metadata24.license_files` to the sdist root, resolving the source the same way `write_dist_info` does for wheels. A file already present at that path is kept, so layouts that work today are unchanged; if its content differs from the license file maturin found, print a warning. Fixes PyO3#3327
messense
force-pushed
the
fix/sdist-workspace-license-files
branch
from
October 21, 2026 14:02
98693fa to
49f42b4
Compare
messense
enabled auto-merge (squash)
October 21, 2026 14:02
messense
approved these changes
Oct 21, 2026
messense
force-pushed
the
fix/sdist-workspace-license-files
branch
from
October 21, 2026 14:06
dd39f31 to
49f42b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3327.
License-Filepaths in an sdist'sPKG-INFOare relative to the sdist root, but only explicitproject.license-fileswere copied there (#2704). Auto-discovered license files (nolicense-files, orlicense-filesinproject.dynamic) and Cargo'slicense-filewere only packaged next to their crate. That is not the sdist root whenpyproject.tomlis moved up for a workspace member, or when the crate is in a subdirectory viamanifest-path. PyPI rejects these uploads, which is howpyo3-introspection0.30.0 failed (worked around in PyO3/pyo3#6528; PyO3/pyo3#6130 had earlier blamed license symlinks for the same failure). For auto-discovered licenses, a wheel built from the sdist also lost them.This adds one pass before
PKG-INFOis written that copies every entry ofmetadata24.license_filesto the sdist root, resolving the source the same waywrite_dist_infodoes for wheels. So everyLicense-FileinPKG-INFOnow exists at that path in the sdist. If a file is already at that path it is kept, so working layouts don't change; if its content differs, maturin prints a warning instead of failing.Before / after,
maturin sdist, thenmaturin buildfrom the unpacked sdist:LICENSE-APACHE+LICENSE-MITanddynamic = ["license-files"](thepyo3-introspectionshape): both missing at the root, and the wheel built from the sdist had no licenses → both at the root, and both in the wheelpyproject.toml+LICENSEat the root, crate inrust/viamanifest-path:LICENSEnot in the sdist at all, and the wheel had no license → included, and in the wheellicense-files, and a plain single-crate package: sdists byte-identical to beforeLICENSEat that path: sdist byte-identical to before, plus a warningTesting:
sdist_auto_discovered_license_files_at_sdist_rootcovers the workspace-member andmanifest-pathlayouts. It fails on main and passes with this change.pyo3-introspectionsdist at PyO3240dae5(just before pyo3-introspection sdist: skip maturin license lookup pyo3#6528) now has both licenses at the root, and a wheel built from it includes them.twine checkpasses on the broken sdist, so the test parsesPKG-INFOand checks eachLicense-Fileagainst the tarball directly.cargo test --test run -- sdist pep517andcargo test --libpass (on Windows), andcargo fmtis clean.cargo clippy --tests --all-features -- -D warningsstops on 11 unused imports in the#[cfg(unix)]tests ofsrc/module_writer/mod.rs; main has the same errors.#2531 reported the same symptom earlier and was closed by the PEP 639 work (#2647), which didn't cover auto-discovered files. #3049 (including arbitrary workspace-root files) is related but not addressed here.
Thanks to @davidhewitt for the report and the analysis in PyO3/pyo3#6528, and to @Viicos for narrowing it down to the non-explicit
license-filescase.I used Claude to help investigate and write this; I reviewed and tested every change.