Skip to content

fix: filter non-module site_paths and collapse split packages in modules_mapping - #371

Merged
jvolkman merged 1 commit into
mainfrom
fix/modules-mapping-site-paths
Oct 18, 2026
Merged

jvolkman merged 1 commit into
mainfrom
fix/modules-mapping-site-paths

Conversation

@jvolkman

Copy link
Copy Markdown
Owner

Summary

Fixes two regressions in pycross_modules_mapping introduced when #364 (840b79e) expanded PycrossPackageInfo.site_paths to include all files in namespace directories and split regular packages containing shared libraries below namespaces:

  1. Reject non-module files in site_paths: Validate /-separated path segments with _is_valid_identifier before joining with ., after stripping recognized module extensions (.pth, .so, .py, .pyd + .cpython-* / .abi3*) from the leaf filename. Previously, _strip_extensions(tlp).replace("/", ".") ran before _is_valid_module_name, causing files with dots in their filename (such as .pyi, .proto, py.typed, .sip, .toml, .api, .c, .h, .qml, .qm, .json, .md) to pass validation as fake dotted submodule names.
  2. Collapse split packages below namespaces: Strip a trailing __init__ segment when a package directory is split into <pkg>/__init__.py plus individual sibling files/subdirectories, and collapse child module entries whose dot-ancestor already maps to the same package (preserving distinct subpackages owned by different distributions in a shared namespace).

Test Plan

  • Added unit tests in tests/unit/test_modules_mapping.bzl (//tests/unit:test_modules_mapping).

@jvolkman
jvolkman merged commit bfc3b7e into main Oct 18, 2026
76 checks passed
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.

1 participant