pycross_wheel_library: enable implicit namespace packages#216
Open
tobyh-canva wants to merge 1 commit intojvolkman:mainfrom
Open
pycross_wheel_library: enable implicit namespace packages#216tobyh-canva wants to merge 1 commit intojvolkman:mainfrom
pycross_wheel_library: enable implicit namespace packages#216tobyh-canva wants to merge 1 commit intojvolkman:mainfrom
Conversation
## Context Currently, `pycross_wheel_library` installs wheels and unconditionally converts any implicit namespace packages into legacy `pkgutil`-style namespace packages. This `pkgutil`-style conversion can be problematic and unexpected in a lot of cases, and should be unnecessary beyond Python 3.3 when the `--incompatible_default_to_explicit_init_py=true` Bazel flag is set. Looking at the `pycross_wheel_library` rule implementation, and the source code of `wheel_installer.py`, it appears as though there was an intention to allow users to disable this `pkgutil`-style conversion, but the option isn't exposed via the Bazel interfaces, and it's also not used inside the script itself. ## Intent Allow users to disable the automatic conversion of PEP 420 implicit namespace packages to `pkgutil`-style namespace packages, whilst maintaining backwards compatibility. ## Changes - Introduce a boolean bazelrc flag, `--@rules_pycross//config_settings:default_enable_implicit_namespace_pkgs`, to configure the default behaviour of enabling implicit namespace packages in `pycross_wheel_library`. - Update the `pycross_wheel_library` rule and ``wheel_installer.py` script to respect the flag. - Document the flag.
tobyh-canva
commented
Feb 1, 2026
Author
There was a problem hiding this comment.
Just FYI, I wrote this doc by hand, it's not generated 😅 I couldn't figure out a way to use stardoc to generate docs for a Bazel flag. LMK if there's a preferred way to generate this doc.
Comment on lines
+118
to
+119
| "enable_implicit_namespace_pkgs": attr.int( | ||
| default = -1, |
Author
There was a problem hiding this comment.
There are no tests for this option. I'd be happy to add some, but I'm not sure where they should go - in //e2e or //pycross/tests? And if so, should I just check in a dummy wheel file containing a namespace package? Please LMK what you would prefer 🙏
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.
Context
Currently,
pycross_wheel_libraryinstalls wheels and unconditionally converts any implicit namespace packages into legacypkgutil-style namespace packages.This
pkgutil-style conversion can be problematic and unexpected in a lot of cases, and should be unnecessary beyond Python 3.3 when the--incompatible_default_to_explicit_init_py=trueBazel flag is set.Looking at the
pycross_wheel_libraryrule implementation, and the source code ofwheel_installer.py, it appears as though there was an intention to allow users to disable thispkgutil-style conversion, but the option isn't exposed via the Bazel interfaces, and it's also not used inside the script itself.Intent
Allow users to disable the automatic conversion of PEP 420 implicit namespace packages to
pkgutil-style namespace packages, whilst maintaining backwards compatibility.Changes
--@rules_pycross//config_settings:default_enable_implicit_namespace_pkgs, to configure the default behaviour of enabling implicit namespace packages inpycross_wheel_library.pycross_wheel_libraryrule andwheel_installer.pyscript to respect the flag.