aspect-build / rules_py

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

[Bug]: Wrong delimiter in conflict detection code? #359

Closed tgeng closed 1 month ago

tgeng commented 4 months ago

What happened?

When site-packages have conflicts, I am getting a panic like

==================== Test output for //path/to:some_test:
thread 'main' panicked at py/tools/py/src/pth.rs:146:14:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
================================================================================

Looking at the code it seems to me that the following line should be site-packages rather than .runefiles/

https://github.com/aspect-build/rules_py/blob/main/py/tools/py/src/pth.rs#L144

Apparently, tgt seems to be pointing to the "source" (for example <execroot>/_main/bazel-out/k8-fastbuild/bin/external/some~external~module/some/pypi/package/site-packages/some/python/file.py), so it won't contain any .runfiles in the path.

Version

Development (host) and target OS/architectures:

Output of bazel --version:

bazel version Bazelisk version: v1.11.0 Build label: 7.2.0 Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer Build time: Mon Jun 10 13:04:32 2024 (1718024672) Build timestamp: 1718024672 Build timestamp as int: 1718024672

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: Python

How to reproduce

I have two packages without almost identical content and they are both added to `deps` of a `py_test`. Then running `bazel test //path/to/the:test` fails with the above error from rust.

Any other information?

No response

tgeng commented 4 months ago

any thoughts? @mattem

tgeng commented 3 months ago

gentle ping @mattem @alexeagle

mattem commented 3 months ago

Can you provide more complete reproduction steps? I'm not clear on what the issue is here.

tgeng commented 3 months ago

Sure, here is a repro https://github.com/tgeng/pycross_venv_bug_repro

ryanhsanthosh commented 2 months ago

any update on this? i am having the same bug

andyscott commented 1 month ago

I'm also hitting the same issue but with airflow via rules_pycross. My workaround is to set package_collisions = "ignore" on my binary target(s).