fix: physically merge mixed namespace/regular top-level collisions#1199
Draft
acozzette wants to merge 2 commits into
Draft
fix: physically merge mixed namespace/regular top-level collisions#1199acozzette wants to merge 2 commits into
acozzette wants to merge 2 commits into
Conversation
✨ Aspect Workflows Tasks📅 Fri Jun 26 18:12:06 UTC 2026 ✅ 14 successful tasks
⏱ Last updated Fri Jun 26 18:16:39 UTC 2026 · 📊 GitHub API quota 444/15,000 (3% used, resets in 14m) |
py_binary startup benchmark
sys.path quality
✅ No regression detected (PR is -0.3% vs HEAD main) |
When one wheel ships `opentelemetry/__init__.py` (marking `opentelemetry` as a regular package) while others treat it as a PEP 420 namespace, the previous "last winner wins" logic routed all traffic to the non-namespace wheel's directory, hiding the namespace wheels' subpackages. Detect the mixed case (some `is_ns = True`, some `is_ns = False`) and route it to the existing physical-merge mechanism, producing the same layout a flat `pip install` would — one merged directory containing all wheels' contributions. Fixes #1118. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… empty The previous fix triggered a physical merge for ALL mixed namespace/regular top-level collisions, regressing airflow: apache_airflow_core's non-empty airflow/__init__.py (which uses extend_path) was merged into a copied venv directory instead of staying as a symlink into the wheel's install tree. The correct criterion is the __init__.py size. A 0-byte __init__.py (like xds_protos's opentelemetry/__init__.py) is a legacy namespace stub with no extend_path — it cannot merge namespace contributions at runtime, so a physical merge is required. A non-empty __init__.py (like airflow's, 5549 bytes) handles namespace extension itself; the symlink + addsitedir approach continues to work. Detect this in repository.bzl by parsing the size field from RECORD lines for depth-1 __init__.py entries. Propagate via a new empty_init_top_levels field through whl_install attrs → PyWheelsInfo wheel struct. In venv.bzl, only trigger the physical merge when the regular wheel's top-level appears in empty_init_top_levels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
When one wheel ships
opentelemetry/__init__.py(markingopentelemetryas a regular package) while others treat it as a PEP 420 namespace, the previous "last winner wins" logic routed all traffic to the non-namespace wheel's directory, hiding the namespace wheels' subpackages.Detect the mixed case (some
is_ns = True, someis_ns = False) and route it to the existing physical-merge mechanism, producing the same layout a flatpip installwould — one merged directory containing all wheels' contributions.Fixes #1118.
Changes are visible to end-users: yes
Physically merge directories when there is disagreement on whether a package is a namespace package.
Test plan