| commit | 39bd4d8fc0c793aea1ab6b8108ce6eca2bfa1140 | [log] [tgz] |
|---|---|---|
| author | yushan26 <107004874+yushan26@users.noreply.github.com> | Tue Oct 21 12:12:29 2025 -0700 |
| committer | GitHub <noreply@github.com> | Tue Oct 21 19:12:29 2025 +0000 |
| tree | f9fc1110679b52585b9709829bed0a035a858ab9 | |
| parent | cf594f780c91f13d48e77faad34df48ac57398da [diff] |
fix(gazelle) Delete python targets with invalid srcs (#3046)
When running Gazelle, it generated the following target:
```
py_binary(
name = "remove_py_binary",
srcs = ["__main__.py"],
main = "__main__.py",
visibility = ["//visibility:public"],
)
```
After `__main__.py` was deleted and the change committed, re-running
Gazelle did not remove the file from the srcs list.
This change introduces logic to check whether all entries in a Python
target’s srcs attribute correspond to valid files. If none of them
exist, the target is added to result.Empty to signal that it should be
cleaned up. This cleanup behavior applies to when python_generation mode
is package or file, as all `srcs` are expected to reside directly within
the current directory.
---------
Co-authored-by: yushan <yushan@uber.com>
Co-authored-by: Douglas Thor <dougthor42@users.noreply.github.com>This repository is the home of the core Python rules -- py_library, py_binary, py_test, py_proto_library, and related symbols that provide the basis for Python support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
Documentation for rules_python is at https://rules-python.readthedocs.io and in the Bazel Build Encyclopedia.
Examples live in the examples directory.
The core rules are stable. Their implementation is subject to Bazel's backward compatibility policy. This repository aims to follow semantic versioning.
The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See How to contribute page for information on our development workflow.
For detailed documentation, see https://rules-python.readthedocs.io
See Bzlmod support for more details.