You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If two packages install submodules of the same parent module, and if the parent module contains even a vacuous __init__.py file, then a target cannot successfully depend on both packages.
For instance, consider the packages nvidia_cublas_cu11 and nvidia_cuda_cupti_cu11. Each defines a submodule of the common, otherwise empty parent module nvidia. Running pip install nvidia_cublas_cu11 nvidia_cuda_cupti_cu11 will result in a python environment in which both modules can be imported. However a bazel environment provide both externals cannot do so.
The underlying issue here is that while pip installs every package to a common site-packages, rules_python installs each package separately; as a result the pythonpath lookup of the parent module finds one of the packages; whichever one it finds does not contain the other, and so a target may never import both.
As commented in the linked repo, experimental_requirement_cycles doesn't help with this. However the solution might require a new feature similar to experimental_requirement_cycles, in that it will require declaring groups of packages; these groups must share a single site-packages directory into which each member installs.
It's worth noting that this isn't just an NVidia thing: google places the contents of both the google_auth and protobuf packages under a google supermodule. The same is likely true of other commercial vendors.
The text was updated successfully, but these errors were encountered:
Affected Rule
The issue is caused by the rule:
pip_parse
Is this a regression?
No
Description
If two packages install submodules of the same parent module, and if the parent module contains even a vacuous
__init__.py
file, then a target cannot successfully depend on both packages.For instance, consider the packages
nvidia_cublas_cu11
andnvidia_cuda_cupti_cu11
. Each defines a submodule of the common, otherwise empty parent modulenvidia
. Runningpip install nvidia_cublas_cu11 nvidia_cuda_cupti_cu11
will result in a python environment in which both modules can be imported. However a bazel environment provide both externals cannot do so.🔬 Minimal Reproduction
Here is an example github repository: https://github.com/ggould-tri/rules_python_dup_test
If you run the following, the test runs without bazel and succeeds:
If you run the following, the test runs with bazel and fails:
🔥 Exception or Error
There is no bazel error. The python error is
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_python version:
Anything else relevant?
The underlying issue here is that while
pip
installs every package to a commonsite-packages
,rules_python
installs each package separately; as a result the pythonpath lookup of the parent module finds one of the packages; whichever one it finds does not contain the other, and so a target may never import both.As commented in the linked repo,
experimental_requirement_cycles
doesn't help with this. However the solution might require a new feature similar toexperimental_requirement_cycles
, in that it will require declaring groups of packages; these groups must share a singlesite-packages
directory into which each member installs.It's worth noting that this isn't just an NVidia thing: google places the contents of both the
google_auth
andprotobuf
packages under agoogle
supermodule. The same is likely true of other commercial vendors.The text was updated successfully, but these errors were encountered: