Repository navigation
Support parent-relative pyproject metadata in sdists - #3182
Merged
Merged
Conversation
1 of 2 tasks
Copilot
AI
changed the title
[WIP] Fix sdist installation issue in maturin project
Include May 11, 2026
[project.readme] table-form file at sdist root
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes maturin sdist for Cargo workspace members where pyproject.toml is elevated to the sdist root and [project.readme] uses the PEP 621 table form, ensuring the referenced README is also copied to the sdist root so metadata generation doesn’t fail.
Changes:
- Extend
add_pyproject_metadatato also handleReadMe::Table { file: Some(...) }when copying README into the sdist root. - Add a regression test covering workspace-member
pyproject.tomlwith table-form[project.readme].
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/source_distribution/pyproject.rs | Adds support for table-form [project.readme] so the README is included at the sdist root when pyproject.toml is elevated. |
| tests/run/sdist.rs | Adds a regression test asserting README is present at the archive root for the table-form readme case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
messense
force-pushed
the
copilot/fix-sdist-installation-issue
branch
from
May 11, 2026 13:52
da61e08 to
6c6b9da
Compare
messense
force-pushed
the
copilot/fix-sdist-installation-issue
branch
from
May 11, 2026 13:58
6c6b9da to
db4c966
Compare
messense
force-pushed
the
copilot/fix-sdist-installation-issue
branch
from
May 11, 2026 14:23
db4c966 to
06dad83
Compare
[project.readme] table-form file at sdist root
messense
force-pushed
the
copilot/fix-sdist-installation-issue
branch
from
May 12, 2026 00:47
06dad83 to
464e8c4
Compare
When `pyproject.toml` lives in a subdirectory of a Cargo workspace,
`add_pyproject_metadata` only elevated the readme to the sdist root for
the string form (`readme = "README.md"`). The table form
(`[project.readme]` with `file = "README.md"`) was silently ignored, so
the file remained under the workspace-member subdirectory and `pip
install` of the sdist failed when generating metadata.
Handle the `ReadMe::Table { file, .. }` variant alongside
`ReadMe::RelativePath` so the readme is copied next to `pyproject.toml`
in either case.
Agent-Logs-Url: https://github.com/PyO3/maturin/sessions/c75f929a-fc52-412b-908c-644c020e442b
Co-authored-by: messense <1556054+messense@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PyO3/maturin/sessions/c75f929a-fc52-412b-908c-644c020e442b Co-authored-by: messense <1556054+messense@users.noreply.github.com>
Reject absolute paths and `..` traversal in the `file` values of `[project.readme]` and `[project.license]` before adding them to the sdist. Otherwise such paths could place files at surprising locations in the archive or read files outside the project directory when the sdist copies them next to `pyproject.toml`. Agent-Logs-Url: https://github.com/PyO3/maturin/sessions/304ac3d5-d758-482b-9beb-8d13060340e7 Co-authored-by: messense <1556054+messense@users.noreply.github.com>
Combine the validate/dedupe/add steps for files referenced from
`pyproject.toml` (`project.readme.file`, `project.license.file`) into a
single `add_pyproject_relative_file` helper. Previously the call sites
duplicated the `root_dir.join` / `writer.contains_target` / `writer.add_file`
sequence, and a separate `check_pyproject_relative_path` only validated
the path.
Also collapse the `pyproject_toml::ReadMe` match into a single or-pattern
covering both `RelativePath(file)` and `Table { file: Some(file), .. }`,
and let the helper take `impl AsRef<Path>` so it accepts the readme's
`String` and the license's `PathBuf` without per-call-site conversions.
No behavior change.
Allow Cargo-generated sdists to include pyproject readme and license files that live above a workspace member, rewriting the root pyproject.toml paths to their archive locations. Reject those parent-relative metadata paths for the git sdist generator so its output remains faithful to git ls-files.
messense
force-pushed
the
copilot/fix-sdist-installation-issue
branch
from
May 12, 2026 13:01
464e8c4 to
2bdb8d4
Compare
messense
marked this pull request as ready for review
May 13, 2026 00:23
2 tasks done
JustinTong0323
added a commit
to JustinTong0323/sglang
that referenced
this pull request
Jun 12, 2026
maturin 1.14 (PyO3/maturin#3182, "Support parent-relative pyproject metadata in sdists") bounds a parent-relative `project.readme` to the cargo workspace root. sgl-model-gateway has no [workspace], so cargo metadata reports each crate's own directory as the workspace root and the python bindings' `readme = "../../README.md"` is rejected: `project.readme` path `../../README.md` resolves outside allowed metadata root `/build/sgl-model-gateway/bindings/python` This breaks every `maturin build` run from bindings/python (the dev, gateway and rocm docker images, pr-test-rust, and the PyPI release). Declare sgl-model-gateway as the workspace root with bindings/python as a member; the golang bindings and wasm examples stay standalone via `exclude`. The workspace root now contains README.md, so the existing parent-relative readme resolves inside the allowed root with no change to which README ships on PyPI. Build profiles already live at the workspace root, so the duplicate [profile.ci] in bindings/python is dropped (workspace members' profile tables are ignored by cargo). Joining the workspace also brings bindings/python/src/lib.rs under the gateway rustfmt config, so apply `cargo +nightly fmt` to it.
netbsd-srcmastr
pushed a commit
to NetBSD/pkgsrc
that referenced
this pull request
Jun 23, 2026
## 1.14.1 * Bump uraimo/run-on-arch-action to v3 to fix pytest job ([#3221](PyO3/maturin#3221)) * Fix platform tag logic to generate the same as cpython on AIX ([#3220](PyO3/maturin#3220)) * Bump pyo3-introspection ([#3227](PyO3/maturin#3227)) * Upgrade cargo-zigbuild & cargo-xwin ([#3228](PyO3/maturin#3228)) * Fix issues around crates enabling abi3 and abi3t features ([#3226](PyO3/maturin#3226)) * Add PEP 740 publish attestations to PyPI releases ([#3230](PyO3/maturin#3230)) * Set PYO3_PYTHON to run scripts for stable ABI builds ([#3233](PyO3/maturin#3233)) * Fix shell quoting in CI scripts ([#3231](PyO3/maturin#3231)) ## 1.14.0 * Support parent-relative pyproject metadata in sdists ([#3182](PyO3/maturin#3182)) * Update PyPI platform tag validation ([#3187](PyO3/maturin#3187)) * Maint: update setup emsdk action in generate-ci ([#3194](PyO3/maturin#3194)) * Fix: only shim bin wheels during auditwheel repair ([#3197](PyO3/maturin#3197)) * Fix: avoid editable ELF truncation from stale hardlinks ([#3199](PyO3/maturin#3199)) * Fix Pyodide Emscripten platform tags ([#3191](PyO3/maturin#3191)) * Use pax instead of GNU headers for tar ([#3203](PyO3/maturin#3203)) * Feat: add default exclude `__pycache__` and `*.pyc` files ([#3202](PyO3/maturin#3202)) * Add support for finding free-threaded interpreters for `--find-interpreters` ([#3206](PyO3/maturin#3206)) * Stubs: also generate them for mixed PyO3 projects ([#3211](PyO3/maturin#3211)) * Don't depend on CFFI on PyPy ([#3213](PyO3/maturin#3213)) * Support pyo3 abi3t features on Python3.15 and PyO3 0.29 ([#3113](PyO3/maturin#3113))
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
maturin 1.14.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed * Support parent-relative pyproject metadata in sdists by @Copilot in PyO3/maturin#3182 * Update PyPI platform tag validation by @messense in PyO3/maturin#3187 * maint: update setup emsdk action in generate-ci by @ManonMarchand in PyO3/maturin#3194 * fix: only shim bin wheels during auditwheel repair by @messense in PyO3/maturin#3197 * fix: avoid editable ELF truncation from stale hardlinks by @messense in PyO3/maturin#3199 * Fix Pyodide Emscripten platform tags by @messense in PyO3/maturin#3191 * build(deps): bump openssl from 0.10.79 to 0.10.80 by @dependabot[bot] in PyO3/maturin#3200 * Use pax instead of GNU headers for tar by @konstin in PyO3/maturin#3203 * feat: add default exclude __pycache__ and *.pyc files by @GuYeying in PyO3/maturin#3202 * Documentation: fix the update_readme script by @ManonMarchand in PyO3/maturin#3186 * Fix python versions used in integration_pyo3_mixed_conda by @ngoldbaum in PyO3/maturin#3208 * Add support for finding free-threaded interpreters for --find-interpreters by @ngoldbaum in PyO3/maturin#3206 * build(deps): bump tar from 0.4.45 to 0.4.46 by @dependabot[bot] in PyO3/maturin#3209 * Stubs: also generate them for mixed PyO3 projects by @Tpt in PyO3/maturin#3211 * Don't depend on CFFI on PyPy by @ngoldbaum in PyO3/maturin#3213 * resolve_platform_tags: remove a redundant case by @Tpt in PyO3/maturin#3214 * GeneratorOutput::additional_files remove Option by @Tpt in PyO3/maturin#3215 * Support pyo3 abi3t features on Python3.15 and PyO3 0.29 by @ngoldbaum in PyO3/maturin#3113 ## New Contributors * @GuYeying made their first contribution in PyO3/maturin#3202 **Full Changelog**: https://github.com/PyO3/maturin/compare/v1.13.3...v1.14.0</pre> <p>View the full release notes at <a href="https://github.com/PyO3/maturin/releases/tag/v1.14.0">https://github.com/PyO3/maturin/releases/tag/v1.14.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11404
tsutsui
pushed a commit
to tsutsui/pkgsrc
that referenced
this pull request
Oct 17, 2026
## 1.14.1 * Bump uraimo/run-on-arch-action to v3 to fix pytest job ([#3221](PyO3/maturin#3221)) * Fix platform tag logic to generate the same as cpython on AIX ([#3220](PyO3/maturin#3220)) * Bump pyo3-introspection ([#3227](PyO3/maturin#3227)) * Upgrade cargo-zigbuild & cargo-xwin ([#3228](PyO3/maturin#3228)) * Fix issues around crates enabling abi3 and abi3t features ([#3226](PyO3/maturin#3226)) * Add PEP 740 publish attestations to PyPI releases ([#3230](PyO3/maturin#3230)) * Set PYO3_PYTHON to run scripts for stable ABI builds ([#3233](PyO3/maturin#3233)) * Fix shell quoting in CI scripts ([#3231](PyO3/maturin#3231)) ## 1.14.0 * Support parent-relative pyproject metadata in sdists ([#3182](PyO3/maturin#3182)) * Update PyPI platform tag validation ([#3187](PyO3/maturin#3187)) * Maint: update setup emsdk action in generate-ci ([#3194](PyO3/maturin#3194)) * Fix: only shim bin wheels during auditwheel repair ([#3197](PyO3/maturin#3197)) * Fix: avoid editable ELF truncation from stale hardlinks ([#3199](PyO3/maturin#3199)) * Fix Pyodide Emscripten platform tags ([#3191](PyO3/maturin#3191)) * Use pax instead of GNU headers for tar ([#3203](PyO3/maturin#3203)) * Feat: add default exclude `__pycache__` and `*.pyc` files ([#3202](PyO3/maturin#3202)) * Add support for finding free-threaded interpreters for `--find-interpreters` ([#3206](PyO3/maturin#3206)) * Stubs: also generate them for mixed PyO3 projects ([#3211](PyO3/maturin#3211)) * Don't depend on CFFI on PyPy ([#3213](PyO3/maturin#3213)) * Support pyo3 abi3t features on Python3.15 and PyO3 0.29 ([#3113](PyO3/maturin#3113))
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 #3181.
When
pyproject.tomllives in a Cargo workspace member,maturin sdistplacespyproject.tomlat the sdist root as required by the source distribution format. If PEP 621 metadata such as[project.readme] file = "../README.md"orlicense = { file = "../LICENSE" }points outside the member directory, the elevatedpyproject.tomlused to keep paths that no longer resolved from the sdist root, causingpip install <sdist>metadata generation to fail.Changes
project.readmeandproject.license.filemetadata files referenced frompyproject.toml, including parent-relative paths that stay within the Cargo workspace.pyproject.tomlso they point at the files' archive locations.PKG-INFO/License-Filemetadata aligned with the rewritten sdist layout for parent-relativeproject.license.file.git ls-files.pyproject.tomlreferences parent metadata files, and for the Git-generator rejection case.Notes
The Cargo sdist path is intentionally allowed to copy and rewrite these metadata files because it already constructs an archive layout around Cargo workspace membership and path dependencies. The Git sdist path intentionally does not do this: it should package exactly what
git ls-filesreports from thepyproject.tomldirectory, so parent-relative metadata paths are reported as unsupported there.