Skip to content

namespace packages broken because pkgutil shims not generated by default #3038

@philsc

Description

@philsc

🐞 bug report

Affected Rule

I'm assuming there's some issue in py_binary or py_library. Not sure.

Is this a regression?

Yes, 1.4.1 appears to work, but 1.5.0-rc4 does not.

Description

I can no longer import the kfp.compiler module.

🔬 Minimal Reproduction

Check out the reproduction here: https://github.com/philsc/rules_python-repro/tree/repro-kfp-1.5.0-rc4

The README showcases the issue I'm running into.

🔥 Exception or Error

Doing this:

import kfp
print(kfp)

import kfp.compiler
print(kfp.compiler)

And having this BUILD target:

py_binary(
    name = "bin",
    srcs = ["bin.py"],
    deps = [
        requirement("kfp"),
    ],
)

results in this error:

<module 'kfp' from '/data/phil_cache/bazel/_bazel_philipp.schrader/29d62092ea113224b51636420449a2d3/execroot/__main__/bazel-out/k8-fastbuild/bin/bin.runfiles/my_deps_kfp_pipeline_spec/site-packages/kfp/__init__.py'>
Traceback (most recent call last):
  File "/data/phil_cache/bazel/_bazel_philipp.schrader/29d62092ea113224b51636420449a2d3/execroot/__main__/bazel-out/k8-fastbuild/bin/bin.runfiles/__main__/bin.py", line 4, in <module>
    import kfp.compiler
ModuleNotFoundError: No module named 'kfp.compiler'

Rules_python version:

1.5.0

Workaround

Set pip.parse.enable_implicit_namespace_pkgs = True in 1.5

Note that this will have to be changed to False in subsequent versions; the bug is an inverted logic check after some refactoring.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions