aspect-build / rules_py

More compatible Bazel rules for running Python tools and building Python projects
Apache License 2.0
84 stars 23 forks source link

[Bug]: Conflicting symlinks found when attempting to create venv. #358

Closed anuragkanungo closed 2 months ago

anuragkanungo commented 3 months ago

What happened?

Using version 0.7.3 I am seeing

-----------------------------------------------------------------------------
Error:   × Unable to run command:
  ├─▶ Conflicting symlinks found when attempting to create venv. More than one
  │   package provides the file at these paths
  ├─▶ pip_deps_mcap_protobuf_support/site-packages/tests/test_writer.py
  ╰─▶ site-packages/tests/test_writer.py

These are the files

./bazel-voxel/external/pip_deps_mcap/site-packages/tests/test_writer.py
./bazel-voxel/external/pip_deps_mcap_protobuf_support/site-packages/tests/test_writer.py

In a typical pip installation the second file overwrites the first one.

Version

Development (host) and target OS/architectures: Linux x86-64

Output of bazel --version: bazel 7.1.0

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file: 0.7.3

Language(s) and/or frameworks involved:

How to reproduce

Adding these pip packages

mcap==0.0.15
mcap-protobuf-support==0.0.9


### Any other information?

_No response_
mattem commented 3 months ago

In a typical pip installation the second file overwrites the first one.

Are the file contents checked before overwriting, or only the name taken into consideration? If so, then which one wins? My concern is that the ordering of the dependencies matter here, and rules_py will need to ensure the same dependency ordering as pip, which may not be possible.

In this case, both those libraries should not be shipping test cases into the distribution package.

alexeagle commented 2 months ago

Discussed with Matt that this injected __init__.py that rules_python puts in namespaced-packages https://github.com/bazelbuild/rules_python/blob/03854a20c39e9e9bfebe91802102715cb027220a/python/private/pypi/whl_installer/namespace_pkgs.py#L95-L96 is a particularly gross violation triggering this error.

Will probably just allow these conflicting symlinks and print a warning, then add a flag letting you suppress that warning.

hofbi commented 2 months ago

I get a similar error

Error:   × Unable to run command:
  ├─▶ Conflicting symlinks found when attempting to create venv. More than one
  │   package provides the file at these paths
  ├─▶ rules_python~~pip~rules_ros_pip_deps_38_pyyaml/site-packages/yaml/
  │   loader.py
  ╰─▶ site-packages/yaml/loader.py

Allowing these conflicts and printing a warning seems like a reasonable approach.