From c74a8cecb48e1f1ff8ef0f26f1701a07a0772157 Mon Sep 17 00:00:00 2001 From: yushan Date: Mon, 16 Jun 2025 19:51:42 +0000 Subject: [PATCH 1/3] (gazelle) Always generate BUILD rules in a new folder regardless if it has entrypoint file --- gazelle/python/generate.go | 2 -- gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out | 2 +- gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gazelle/python/generate.go b/gazelle/python/generate.go index 5eedbd9601..2f7ee02036 100644 --- a/gazelle/python/generate.go +++ b/gazelle/python/generate.go @@ -85,8 +85,6 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes if parent != nil && parent.CoarseGrainedGeneration() { return language.GenerateResult{} } - } else if !hasEntrypointFile(args.Dir) { - return language.GenerateResult{} } } diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out index 1c56f722d4..5f131b5730 100644 --- a/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out +++ b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out @@ -11,5 +11,5 @@ py_binary( srcs = ["__main__.py"], main = "__main__.py", visibility = ["//:__subpackages__"], - deps = [":has_main"], + deps = ["//foo"], ) diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out index a99278ec79..0ce1c5d378 100644 --- a/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out +++ b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out @@ -10,5 +10,5 @@ py_test( name = "has_test_test", srcs = ["__test__.py"], main = "__test__.py", - deps = [":has_test"], + deps = ["//foo"], ) From d11a7c5b2e130e05adabb1af32444f1fd693d4fb Mon Sep 17 00:00:00 2001 From: yushan Date: Mon, 16 Jun 2025 20:06:07 +0000 Subject: [PATCH 2/3] update --- gazelle/python/testdata/subdir_sources/BUILD.in | 1 + gazelle/python/testdata/subdir_sources/BUILD.out | 3 +++ gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out | 2 +- gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gazelle/python/testdata/subdir_sources/BUILD.in b/gazelle/python/testdata/subdir_sources/BUILD.in index e69de29bb2..adfdefdc8a 100644 --- a/gazelle/python/testdata/subdir_sources/BUILD.in +++ b/gazelle/python/testdata/subdir_sources/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_generation_mode project diff --git a/gazelle/python/testdata/subdir_sources/BUILD.out b/gazelle/python/testdata/subdir_sources/BUILD.out index d03a8f05ac..5d77890d4f 100644 --- a/gazelle/python/testdata/subdir_sources/BUILD.out +++ b/gazelle/python/testdata/subdir_sources/BUILD.out @@ -1,5 +1,8 @@ + load("@rules_python//python:defs.bzl", "py_binary") +# gazelle:python_generation_mode project + py_binary( name = "subdir_sources_bin", srcs = ["__main__.py"], diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out index 5f131b5730..1c56f722d4 100644 --- a/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out +++ b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out @@ -11,5 +11,5 @@ py_binary( srcs = ["__main__.py"], main = "__main__.py", visibility = ["//:__subpackages__"], - deps = ["//foo"], + deps = [":has_main"], ) diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out index 0ce1c5d378..a99278ec79 100644 --- a/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out +++ b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out @@ -10,5 +10,5 @@ py_test( name = "has_test_test", srcs = ["__test__.py"], main = "__test__.py", - deps = ["//foo"], + deps = [":has_test"], ) From 3ae39ee51d213bb735b12258571a93c67a05000a Mon Sep 17 00:00:00 2001 From: yushan Date: Mon, 23 Jun 2025 17:53:24 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4facff4917..f5f058a595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ END_UNRELEASED_TEMPLATE to the package path. This is enabled via the `# gazelle:experimental_allow_relative_imports` true directive ({gh-issue}`2203`). * (gazelle) Types for exposed members of `python.ParserOutput` are now all public. +* (gazelle) Remove entry point file requirements when generating rules. {#v0-0-0-fixed} ### Fixed