feat: keep main module in py_library (#1608)
Unlike Go, the main module of Python can still be imported by other
modules. We should keep them in the `py_library` target to allow such
imports.
diff --git a/gazelle/python/generate.go b/gazelle/python/generate.go
index f812f17..8d147d9 100644
--- a/gazelle/python/generate.go
+++ b/gazelle/python/generate.go
@@ -248,7 +248,6 @@
fqTarget.String(), actualPyBinaryKind, err)
continue
}
- srcs.Remove(filename)
pyBinary := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames).
addVisibility(visibility).
addSrc(filename).
diff --git a/gazelle/python/testdata/binary_without_entrypoint/BUILD.out b/gazelle/python/testdata/binary_without_entrypoint/BUILD.out
index c88f2ff..9dae147 100644
--- a/gazelle/python/testdata/binary_without_entrypoint/BUILD.out
+++ b/gazelle/python/testdata/binary_without_entrypoint/BUILD.out
@@ -24,6 +24,8 @@
srcs = [
"__init__.py",
"collided_main.py",
+ "main.py",
+ "main2.py",
],
visibility = ["//:__subpackages__"],
)