rules_zapp/example/BUILD

85 lines
1.4 KiB
Python
Raw Normal View History

2021-08-09 15:26:06 +00:00
load("@rules_zapp//zapp:zapp.bzl",
"zapp_binary",
2021-08-30 00:44:43 +00:00
"zapp_test",
2021-08-09 15:26:06 +00:00
)
load("@rules_python//python:defs.bzl",
"py_library",
"py_runtime_pair"
)
2021-08-09 15:26:06 +00:00
load("@my_deps//:requirements.bzl",
py_requirement="requirement",
)
# Configuring a Python runtime
py_runtime(
name = "python3_runtime",
files = [],
interpreter_path = "/usr/bin/python3",
python_version = "PY3",
visibility = ["//visibility:public"],
)
py_runtime_pair(
name = "python_runtime",
py2_runtime = None,
py3_runtime = ":python3_runtime",
)
toolchain(
name = "python3_toolchain",
toolchain = ":python_runtime",
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
)
# Zapp examples & tests
2021-08-30 03:41:20 +00:00
py_test(
name = "hello_native",
main = "hello.py",
srcs = ["hello.py"],
)
2021-08-30 00:44:43 +00:00
zapp_test(
2021-08-09 15:26:06 +00:00
name = "hello_script",
main = "hello.py",
# entry_point is inferred from main =
)
2021-08-30 00:44:43 +00:00
zapp_test(
2021-08-09 15:26:06 +00:00
name = "hello_deps",
main = "hello.py",
# deps also get zapped via their underlying wheels
deps = [
py_requirement("pyyaml"),
]
)
py_library(
name = "lib_hello",
srcs = [],
deps = [
py_requirement("pyyaml"),
]
)
2021-08-30 00:44:43 +00:00
zapp_test(
name = "hello_lib_deps",
main = "hello.py",
deps = [
":lib_hello",
],
)
2021-08-30 00:44:43 +00:00
zapp_test(
name = "hello_unzipped",
zip_safe = False,
main = "hello.py",
deps = [
":lib_hello",
],
)