Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ END_UNRELEASED_TEMPLATE

{#v0-0-0-fixed}
### Fixed
* (gazelle) `py_library` and `py_test` targets with missing source files are now
removed by Gazelle, matching the existing behavior for `py_binary` targets.
Previously, deleting a `.py` file in per-file generation mode left orphaned
targets in BUILD files, causing build failures
([#3375](https://github.com/bazel-contrib/rules_python/issues/3375)).
* (bootstrap) Fixed a potential race condition with symlink creation during
startup.
* (gazelle) Fixed handling of auto-included `__init__.py` files when generating `py_binary`
Expand Down
6 changes: 6 additions & 0 deletions gazelle/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "rules_python", version = "0.18.0")
bazel_dep(name = "rules_go", version = "0.59.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "gazelle", version = "0.47.0", repo_name = "bazel_gazelle")

git_override(
module_name = "gazelle",
commit = "73215247ebf853131af5615a3d460c43530272f1",
remote = "https://github.com/taowang487/bazel-gazelle.git",
)
bazel_dep(name = "rules_cc", version = "0.0.16")

local_path_override(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load(":mylib.bzl", "my_py_library", "my_py_test")

# gazelle:python_generation_mode file
# gazelle:alias_kind my_py_library py_library
# gazelle:alias_kind my_py_test py_test

my_py_library(
name = "bar",
srcs = ["bar.py"],
visibility = ["//:__subpackages__"],
)

my_py_library(
name = "deleted_lib",
srcs = ["deleted.py"],
visibility = ["//:__subpackages__"],
)

my_py_test(
name = "bar_test",
srcs = ["bar_test.py"],
)

my_py_test(
name = "deleted_test",
srcs = ["deleted_test.py"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load(":mylib.bzl", "my_py_library", "my_py_test")

# gazelle:python_generation_mode file
# gazelle:alias_kind my_py_library py_library
# gazelle:alias_kind my_py_test py_test

my_py_library(
name = "bar",
srcs = ["bar.py"],
visibility = ["//:__subpackages__"],
)

my_py_test(
name = "bar_test",
srcs = ["bar_test.py"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a Bazel workspace for the Gazelle test data.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
33 changes: 33 additions & 0 deletions gazelle/python/testdata/remove_invalid_per_file_map_kind/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@rules_python//python:defs.bzl", "py_library")
load(":mylib.bzl", "my_py_binary", "my_py_test")

# gazelle:python_generation_mode file
# gazelle:map_kind py_binary my_py_binary :mylib.bzl
# gazelle:map_kind py_test my_py_test :mylib.bzl

py_library(
name = "bar",
srcs = ["bar.py"],
visibility = ["//:__subpackages__"],
)

py_library(
name = "deleted_lib",
srcs = ["deleted.py"],
visibility = ["//:__subpackages__"],
)

my_py_binary(
name = "deleted_bin",
srcs = ["deleted_bin.py"],
)

my_py_test(
name = "bar_test",
srcs = ["bar_test.py"],
)

my_py_test(
name = "deleted_test",
srcs = ["deleted_test.py"],
)
17 changes: 17 additions & 0 deletions gazelle/python/testdata/remove_invalid_per_file_map_kind/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@rules_python//python:defs.bzl", "py_library")
load(":mylib.bzl", "my_py_test")

# gazelle:python_generation_mode file
# gazelle:map_kind py_binary my_py_binary :mylib.bzl
# gazelle:map_kind py_test my_py_test :mylib.bzl

py_library(
name = "bar",
srcs = ["bar.py"],
visibility = ["//:__subpackages__"],
)

my_py_test(
name = "bar_test",
srcs = ["bar_test.py"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a Bazel workspace for the Gazelle test data.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---