When using these rules with a family of pip packages (e.g. azure and google packages) which install as part of the same "namespace", python is unable to import them at runtime.
For example, if I try to use azure-mgmt-compute which provides the azure.mgmt.compute module and azure-mgmt-resource which provides the azure.mgmt.resource module, I run into this issue since they both install into the azure top level module. My pylint rules complain
ben.py:10:0: E0611: No name 'mgmt' in module 'azure' (no-name-in-module)
ben.py:10:0: E0401: Unable to import 'azure.mgmt' (import-error)
as well as when I go to actually run the packaged up par:
File "path/to/file/ben.py", line 14, in <module>
from azure.mgmt import compute, network, resource
ModuleNotFoundError: No module named 'azure.mgmt'
The build of the target succeeds, so only at run time does it fail.
I've found that this seems to be a known issue with bazel's rules_python which I found through this issue which I found through this issue (where this rule set is said to possibly fix this issue).
The repo for rules_python_external seems to have solved this issue and after doing some digging, it looks like they handle this by detecting and treating those "namespace" packages on wheel extraction.
When using these rules with a family of pip packages (e.g.
azureandgooglepackages) which install as part of the same "namespace", python is unable to import them at runtime.For example, if I try to use
azure-mgmt-computewhich provides theazure.mgmt.computemodule andazure-mgmt-resourcewhich provides theazure.mgmt.resourcemodule, I run into this issue since they both install into theazuretop level module. My pylint rules complainas well as when I go to actually run the packaged up par:
The build of the target succeeds, so only at run time does it fail.
I've found that this seems to be a known issue with bazel's
rules_pythonwhich I found through this issue which I found through this issue (where this rule set is said to possibly fix this issue).The repo for rules_python_external seems to have solved this issue and after doing some digging, it looks like they handle this by detecting and treating those "namespace" packages on wheel extraction.