rules_zapp/example/BUILD
Reid 'arrdem' McKenzie edd7dd0103 Get an interpreter from toolchains
This patch teaches Zapp how to read Python toolchains to get an
interpreter, rather than hard-coding "python3" somewhat opaquely. This
enables the use of hermetic or otherwise selected interpreters.

Fixes #2
2021-08-29 21:10:34 -06:00

78 lines
1.3 KiB
Python

load("@rules_zapp//zapp:zapp.bzl",
"zapp_binary",
"zapp_test",
)
load("@rules_python//python:defs.bzl",
"py_library",
"py_runtime_pair"
)
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
zapp_test(
name = "hello_script",
main = "hello.py",
# entry_point is inferred from main =
)
zapp_test(
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"),
]
)
zapp_test(
name = "hello_lib_deps",
main = "hello.py",
deps = [
":lib_hello",
],
)
zapp_test(
name = "hello_unzipped",
zip_safe = False,
main = "hello.py",
deps = [
":lib_hello",
],
)