Skip to content

fix(pypi): only generate namespace package shims if implicit namespaces are disabled #3059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 6, 2025

Conversation

rickeylev
Copy link
Collaborator

The refactoring to move the pkgutil shim generation to build phase inverted
the logic for when it should be activated. When
enable_implicit_namespace_pkgs=True, it means to not generate the pkgutil shims
("respect the Python definition of the namespace package").

To fix, just invert the logic that activates it.

A test will be added in a subsequent PR because the necessary helper isn't
in the 1.5 branch.

Fixes #3038

@rickeylev rickeylev requested review from aignas and groodt as code owners July 5, 2025 16:19
@rickeylev
Copy link
Collaborator Author

rickeylev commented Jul 5, 2025

note to self:

  • looks like the tests are using some sort of mock that isn't glob-like enough.
  • Argh, the test calls a rule, so can't actually call create_inits(). I think the test needs to be rewritten as an analysis test or something.

@aignas
Copy link
Collaborator

aignas commented Jul 6, 2025

In order to unblock this I modified the unit test to set the flag to disable the consumption of the glob.

@aignas
Copy link
Collaborator

aignas commented Jul 6, 2025

Thanks for catching this and digging until the end!

@aignas aignas added this pull request to the merge queue Jul 6, 2025
Merged via the queue into bazel-contrib:main with commit 47c681b Jul 6, 2025
2 of 3 checks passed
aignas added a commit that referenced this pull request Jul 6, 2025
…es are disabled (#3059)

The refactoring to move the pkgutil shim generation to build phase
inverted
the logic for when it should be activated. When
`enable_implicit_namespace_pkgs=True`, it means to not generate the
pkgutil shims
("respect the Python definition of the namespace package").

To fix, just invert the logic that activates it.

A test will be added in a subsequent PR because the necessary helper
isn't
in the 1.5 branch.

Fixes #3038

---------

Co-authored-by: Ignas Anikevicius <[email protected]>
(cherry picked from commit 47c681b)
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.

namespace packages broken because pkgutil shims not generated by default
2 participants