Uh oh!
There was an error while loading. Please reload this page.
do not index py_binary unless in file mode - #2989
Conversation
linzhp
commented
Jun 23, 2025
This PR is ready for review. The failing CI is an infra issue |
Uh oh!
There was an error while loading. Please reload this page.
linzhp
commented
Jun 29, 2025
Added tests. Please take another look |
linzhp
commented
Jul 13, 2025
@aignas friendly ping... |
dougthor42
left a comment
There was a problem hiding this comment.
I tested this on our big repo that uses file mode; looks good (eg gazelle didn't cause any unexpected changes).
Request: please update CHANGELOG.md with a fixed entry.
For my own future reference, this is what happens without the fix (eg reverting e9bd803):
=================== Test output for //python:python_test_import_with_same_srcs_library_and_binary:
--- FAIL: TestGazelleBinary (0.00s)
--- FAIL: TestGazelleBinary/import_with_same_srcs_library_and_binary (0.03s)
python_test.go:168: expected gazelle exit code: 0
got: 1
python_test.go:178: expected gazelle stderr: got: gazelle: ERROR: failed to validate dependencies for target "//bar:py_default_library":
"bar/bar.py", line 1: multiple targets (//foo:script, //foo:py_default_library) may be imported with "foo.script": possible solutions:
1. Disambiguate the above multiple targets by removing duplicate srcs entries.
2. Use the '# gazelle:resolve py foo.script TARGET_LABEL' BUILD file directive to resolve to one of the above targets.
"bar/bar.py", line 1: "foo" is an invalid dependency: possible solutions:
1. Add it as a dependency in the requirements.txt file.
2. Use the '# gazelle:resolve py foo TARGET_LABEL' BUILD file directive to resolve to a known dependency.
3. Ignore it with a comment '# gazelle:ignore foo' in the Python file.
FAIL
================================================================================
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
linzhp
commented
Jul 14, 2025
PTAL |
This is yet another implementation of #2822. Based on this:
rules_python/gazelle/python/generate.go
Lines 248 to 252 in 94e08f7
The only case when a python file does not exist in
py_libraryis in file mode. Stop indexingpy_binaryin other mode to avoid ambiguous dependency resolution.