Skip to content

Normalize paths when matching manifest entries to package dirs in build_py - #5309

Open
CAOShurong wants to merge 1 commit into
pypa:mainfrom
CAOShurong:codex/5093-windows-manifest-separators
Open

CAOShurong wants to merge 1 commit into
pypa:mainfrom
CAOShurong:codex/5093-windows-manifest-separators

Conversation

@CAOShurong

Copy link
Copy Markdown

Fixes #5093

Problem

On Windows, a project with an Extension whose 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:

_Warning: Package 'mypkg.lib' is absent from the `packages` configuration.

even though mypkg.lib is explicitly listed in packages, and the source file is misclassified as package data of the parent package (the duplicated copying mypkg/lib/say.pyx ... line in the issue report).

Root cause

build_py.analyze_manifest matches manifest/SOURCES.txt entries against package source directories:

  • Manifest paths are written with forward slashes (mypkg/lib/say.pyx).
  • get_package_dir emits OS-native separators (mypkg\lib on Windows).
  • The directory-climbing loop therefore does not recognize mypkg/lib on the first split, overshoots to the parent dir, and takes the f != oldf branch → importable_subpackage fires 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.normpath before splitting/matching. No behavior change on POSIX.

Verification

  • New regression test test_analyze_manifest_mixed_separators: fails on main (warning emitted), passes with the fix.
  • End-to-end repro from the issue (subpackage + .pyx extension 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 --check clean.

…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
@mergify

mergify Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Weird warning for pure-Cython submodule on Windows

1 participant