Skip to content

Commit e7d5c8d

Browse files
authored
feat: keep main module in py_library (bazel-contrib#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.
1 parent 2b5447b commit e7d5c8d

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

gazelle/python/generate.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes
248248
fqTarget.String(), actualPyBinaryKind, err)
249249
continue
250250
}
251-
srcs.Remove(filename)
252251
pyBinary := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames).
253252
addVisibility(visibility).
254253
addSrc(filename).

gazelle/python/testdata/binary_without_entrypoint/BUILD.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ py_library(
2424
srcs = [
2525
"__init__.py",
2626
"collided_main.py",
27+
"main.py",
28+
"main2.py",
2729
],
2830
visibility = ["//:__subpackages__"],
2931
)

0 commit comments

Comments
 (0)