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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ END_UNRELEASED_TEMPLATE
### Removed
* Nothing removed.

{#1-5-1}
## [1.5.1] - 2025-07-06

[1.5.1]: https://github.com/bazel-contrib/rules_python/releases/tag/1.5.1

{#v1-5-1-fixed}
### Fixed

* (pypi) Namespace packages work by default (pkgutil shims are generated
by default again)
([#3038](https://github.com/bazel-contrib/rules_python/issues/3038)).

{#1-5-0}
## [1.5.0] - 2025-06-11

Expand Down
2 changes: 1 addition & 1 deletion python/private/pypi/whl_library_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def whl_library_targets(
allow_empty = True,
)

if enable_implicit_namespace_pkgs:
if not enable_implicit_namespace_pkgs:
srcs = srcs + getattr(native, "select", select)({
Label("//python/config_settings:is_venvs_site_packages"): [],
"//conditions:default": create_inits(
Expand Down
10 changes: 9 additions & 1 deletion tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@

load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("//python/private:glob_excludes.bzl", "glob_excludes") # buildifier: disable=bzl-visibility
load("//python/private/pypi:whl_library_targets.bzl", "whl_library_targets", "whl_library_targets_from_requires") # buildifier: disable=bzl-visibility
load("//python/private/pypi:whl_library_targets.bzl", _whl_library_targets = "whl_library_targets", _whl_library_targets_from_requires = "whl_library_targets_from_requires") # buildifier: disable=bzl-visibility

_tests = []

def whl_library_targets(**kwargs):
# Let's skip testing this for now
_whl_library_targets(enable_implicit_namespace_pkgs = True, **kwargs)

def whl_library_targets_from_requires(**kwargs):
# Let's skip testing this for now
_whl_library_targets_from_requires(enable_implicit_namespace_pkgs = True, **kwargs)

def _test_filegroups(env):
calls = []

Expand Down