Normalize paths when matching manifest entries to package dirs in build_py - #5309
Open
CAOShurong wants to merge 1 commit into
Open
CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
…ld_py Manifest/SOURCES.txt paths use forward slashes while get_package_dir emits OS-native separators; on Windows the mismatch made analyze_manifest overshoot the package dir, emitting a false 'Package is absent from the packages configuration' warning and misclassifying extension sources (e.g. .pyx files written in the documented Unix form) as parent-package data. Normalize both sides before comparison. Fixes pypa#5093
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
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 #5093
Problem
On Windows, a project with an
Extensionwhose source path is written in the documented, portable Unix form (e.g.Extension("mypkg.lib.say", ["mypkg/lib/say.pyx"])) gets a false warning during wheel builds:even though
mypkg.libis explicitly listed inpackages, and the source file is misclassified as package data of the parent package (the duplicatedcopying mypkg/lib/say.pyx ...line in the issue report).Root cause
build_py.analyze_manifestmatches manifest/SOURCES.txt entries against package source directories:mypkg/lib/say.pyx).get_package_diremits OS-native separators (mypkg\libon Windows).mypkg/libon the first split, overshoots to the parent dir, and takes thef != oldfbranch →importable_subpackagefires the warning and the file is recorded as data of the wrong package.On POSIX both sides use
/so the mismatch never manifests.Fix
Normalize both sides of the comparison with
os.path.normpathbefore splitting/matching. No behavior change on POSIX.Verification
test_analyze_manifest_mixed_separators: fails on main (warning emitted), passes with the fix..pyxextension source, Windows, Python 3.13): warning present on 84.0.0/main, gone with this patch.pytest setuptools/tests/test_build_py.py setuptools/tests/test_editable_install.py: 59 passed, 1 skipped, 5 xfailed.ruff check/ruff format --checkclean.