diff --git a/examples/build_file_generation/BUILD.bazel b/examples/build_file_generation/BUILD.bazel index a378775968..9d45d67ca2 100644 --- a/examples/build_file_generation/BUILD.bazel +++ b/examples/build_file_generation/BUILD.bazel @@ -18,6 +18,8 @@ compile_pip_requirements( requirements_windows = "requirements_windows.txt", ) +# gazelle:python_generation_mode file + # This repository rule fetches the metadata for python packages we # depend on. That data is required for the gazelle_python_manifest # rule to update our manifest file. @@ -57,47 +59,21 @@ gazelle( gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary", ) -# This rule is auto-generated and managed by Gazelle, -# because it found the __init__.py file in this folder. -# See: https://bazel.build/reference/be/python#py_library py_library( - name = "build_file_generation", + name = "__init__", srcs = ["__init__.py"], visibility = ["//:__subpackages__"], deps = [ - "//random_number_generator", + "//random_number_generator:generate_random_number", "@pip//flask", "@pip//sphinx", ], ) -# A py_binary is an executable Python program consisting of a collection of .py source files. -# See: https://bazel.build/reference/be/python#py_binary -# -# This rule is auto-generated and managed by Gazelle, -# because it found the __main__.py file in this folder. -# This rule creates a target named //:build_file_generation_bin and you can use -# bazel to run the target: -# `bazel run //:build_file_generation_bin` py_binary( name = "build_file_generation_bin", srcs = ["__main__.py"], main = "__main__.py", visibility = ["//:__subpackages__"], - deps = [":build_file_generation"], -) - -# A py_test is a Python unit test. -# See: https://bazel.build/reference/be/python#py_test -# -# This rule is auto-generated and managed by Gazelle, -# because it found the __test__.py file in this folder. -# This rule creates a target named //:build_file_generation_test and you can use -# bazel to run the target: -# `bazel test //:build_file_generation_test` -py_test( - name = "build_file_generation_test", - srcs = ["__test__.py"], - main = "__test__.py", - deps = [":build_file_generation"], + deps = [":__init__"], ) diff --git a/examples/build_file_generation/random_number_generator/BUILD.bazel b/examples/build_file_generation/random_number_generator/BUILD.bazel index c77550084f..caab68d796 100644 --- a/examples/build_file_generation/random_number_generator/BUILD.bazel +++ b/examples/build_file_generation/random_number_generator/BUILD.bazel @@ -1,18 +1,33 @@ +load("@rules_python//python:defs.bzl", "py_binary") load("@rules_python//python:py_library.bzl", "py_library") load("@rules_python//python:py_test.bzl", "py_test") py_library( - name = "random_number_generator", - srcs = [ - "__init__.py", - "generate_random_number.py", - ], + name = "__init__", + srcs = ["__init__.py"], visibility = ["//:__subpackages__"], ) -py_test( - name = "random_number_generator_test", - srcs = ["__test__.py"], - main = "__test__.py", - deps = [":random_number_generator"], +py_library( + name = "generate_random_number", + srcs = ["generate_random_number.py"], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "example_bin", + srcs = ["example_bin.py"], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "other_bin", + srcs = ["other_bin.py"], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "before_bin", + srcs = ["before_bin.py"], + visibility = ["//:__subpackages__"], ) diff --git a/examples/build_file_generation/random_number_generator/before_bin.py b/examples/build_file_generation/random_number_generator/before_bin.py new file mode 100644 index 0000000000..77d464cf08 --- /dev/null +++ b/examples/build_file_generation/random_number_generator/before_bin.py @@ -0,0 +1,5 @@ +def main(): + print('hi') + +if __name__ == '__main__': + main() diff --git a/examples/build_file_generation/random_number_generator/example_bin.py b/examples/build_file_generation/random_number_generator/example_bin.py new file mode 100644 index 0000000000..77d464cf08 --- /dev/null +++ b/examples/build_file_generation/random_number_generator/example_bin.py @@ -0,0 +1,5 @@ +def main(): + print('hi') + +if __name__ == '__main__': + main() diff --git a/examples/build_file_generation/random_number_generator/other_bin.py b/examples/build_file_generation/random_number_generator/other_bin.py new file mode 100644 index 0000000000..77d464cf08 --- /dev/null +++ b/examples/build_file_generation/random_number_generator/other_bin.py @@ -0,0 +1,5 @@ +def main(): + print('hi') + +if __name__ == '__main__': + main()