You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(pypi): preserve explicitly included bytecode package initializers - #4607
Wheel data can explicitly include a bytecode package initializer.
Namespace conversion currently writes an __init__.py alongside it.
Python imports that file first, leaving names exported by the wheel's
initializer unavailable.
Recognize __init__.pyc when deciding whether a package already has an
initializer.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
No actionable comments were generated in the recent review.
Walkthrough
Namespace conversion now treats explicitly included __init__.pyc files as package initializers, alongside __init__.py. Tests cover nested bytecode paths and relative and absolute initializer labels. Documentation records the change.
Changes: Namespace package conversion
Layer / File(s)
Summary
Initializer recognition and coverage python/private/pypi/namespace_pkgs.bzl, tests/pypi/namespace_pkgs/namespace_pkgs_tests.bzl, python/private/pypi/attrs.bzl, news/2178.fixed.md
get_files normalizes source labels and handles __init__.pyc like __init__.py. Tests cover nested bytecode paths and relative and absolute initializer labels. The attribute documentation and news entry describe the change.
Namespace conversion no longer creates an __init__.py next to an explicitly included __init__.pyc, so names exported by the wheel's bytecode initializer are no longer hidden. The change is small and covered by tests, and no merge-blocking risk is identified. The failing Buildkite build should be checked to confirm it is unrelated.
Security architecture risk: Minimal · up to e44be
Namespace conversion now leaves explicitly included bytecode initializers unshadowed by its generated source initializers. The fix does not broaden which wheel files are included or change the settings that govern namespace conversion.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: namespace conversion now keeps explicitly included bytecode package initializers (init.pyc) and does not add an init.py beside them. It uses the conventional f…
Description check
The description states the problem: wheel data can include a bytecode initializer, and namespace conversion writes an init.py beside it, which hides the wheel's exported names. It states the fix: …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: namespace conversion now keeps explicitly included bytecode package initializers (init.pyc) and does not add an init.py beside them. It uses the conventional fix(pypi) prefix and matches the raw summary and PR description.
Full details: Description check
Explanation
The description states the problem: wheel data can include a bytecode initializer, and namespace conversion writes an init.py beside it, which hides the wheel's exported names. It states the fix: recognize init.pyc when checking for an existing initializer. This matches the file summaries for namespace_pkgs.bzl, the attrs.bzl docs, and the tests.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
python/private/pypi/namespace_pkgs.bzl-39-39: 1
39-39: Major · Data Integrity & Integration · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Normalize data labels before comparing directories.
whl_library_srcs accepts data labels and passes them to create_inits alongside globbed paths. (raw.githubusercontent.com) If data contains :site-packages/foo/__init__.pyc and the glob finds site-packages/foo/module.py, this records :site-packages/foo as ignored but generates an initializer for site-packages/foo. The generated __init__.py can hide the bytecode exports. Normalize the inputs to comparable paths before checking directories.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
Wheel data can explicitly include a bytecode package initializer.
Namespace conversion currently writes an
__init__.pyalongside it.Python imports that file first, leaving names exported by the wheel's
initializer unavailable.
Recognize
__init__.pycwhen deciding whether a package already has aninitializer.
Work towards #2178.