Skip to content
Closed
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
34 changes: 5 additions & 29 deletions examples/build_file_generation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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__"],
)
35 changes: 25 additions & 10 deletions examples/build_file_generation/random_number_generator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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__"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
print('hi')

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
print('hi')

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
print('hi')

if __name__ == '__main__':
main()