Put the py3 toolchain in the tin
This commit is contained in:
parent
4ee4f3d011
commit
e5686db6cb
5 changed files with 65 additions and 11 deletions
10
WORKSPACE
10
WORKSPACE
|
@ -27,8 +27,18 @@ git_repository(
|
|||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
bazel_skylib_workspace()
|
||||
|
||||
####################################################################################################
|
||||
# rules_python
|
||||
####################################################################################################
|
||||
|
||||
git_repository(
|
||||
name = "rules_python",
|
||||
remote = "https://github.com/bazelbuild/rules_python.git",
|
||||
tag = "0.3.0",
|
||||
)
|
||||
|
||||
# And so that zapp can zapp itself...
|
||||
# Note that consumers DO NOT get this dependency "for free".
|
||||
register_toolchains(
|
||||
"//zapp:python3_toolchain",
|
||||
)
|
||||
|
|
|
@ -36,6 +36,12 @@ toolchain(
|
|||
|
||||
# Zapp examples & tests
|
||||
|
||||
py_test(
|
||||
name = "hello_native",
|
||||
main = "hello.py",
|
||||
srcs = ["hello.py"],
|
||||
)
|
||||
|
||||
zapp_test(
|
||||
name = "hello_script",
|
||||
main = "hello.py",
|
||||
|
|
|
@ -29,12 +29,21 @@ git_repository(
|
|||
tag = "0.3.0",
|
||||
)
|
||||
|
||||
register_toolchains("//:python3_toolchain")
|
||||
load("@rules_python//python:pip.bzl", "pip_install")
|
||||
|
||||
pip_install(
|
||||
name = "my_deps",
|
||||
requirements = "//:requirements.txt",
|
||||
)
|
||||
|
||||
####################################################################################################
|
||||
# rules_zapp
|
||||
####################################################################################################
|
||||
|
||||
# git_repository(
|
||||
# name = "rules_zapp",
|
||||
# remote = "https://github.com/arrdem/rules_zapp.git",
|
||||
# tag = "0.1.1",
|
||||
# tag = "0.1.3",
|
||||
# # branch = "trunk",
|
||||
# )
|
||||
|
||||
|
@ -43,9 +52,7 @@ local_repository(
|
|||
path = "../",
|
||||
)
|
||||
|
||||
load("@rules_python//python:pip.bzl", "pip_install")
|
||||
|
||||
pip_install(
|
||||
name = "my_deps",
|
||||
requirements = "//:requirements.txt",
|
||||
# Use the py3 default toolchain from zapp for a quickstart
|
||||
register_toolchains(
|
||||
"@rules_zapp//zapp:python3_toolchain",
|
||||
)
|
||||
|
|
36
zapp/BUILD
36
zapp/BUILD
|
@ -1,6 +1,36 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("zapp.bzl", "zapp_binary")
|
||||
load("@rules_python//python:defs.bzl",
|
||||
"py_library",
|
||||
"py_runtime",
|
||||
"py_runtime_pair"
|
||||
)
|
||||
|
||||
load("zapp.bzl",
|
||||
"zapp_binary"
|
||||
)
|
||||
|
||||
# The Python runtime we need
|
||||
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 plugins used as a runtime library by rules_zapp
|
||||
py_library(
|
||||
|
@ -11,7 +41,7 @@ py_library(
|
|||
]
|
||||
)
|
||||
|
||||
# Bootstrapping Zapp using py_binary
|
||||
|
||||
py_binary(
|
||||
name = "zappc",
|
||||
main = "compiler/__main__.py",
|
||||
|
@ -23,7 +53,7 @@ py_binary(
|
|||
],
|
||||
)
|
||||
|
||||
# For testing of zappc
|
||||
# Bootstrapping because we can
|
||||
zapp_binary(
|
||||
name = "zappzappc",
|
||||
main = "compiler/__main__.py",
|
||||
|
|
|
@ -177,13 +177,14 @@ _zapp_attrs = {
|
|||
"wheels": attr.label_list(),
|
||||
"entry_point": attr.string(),
|
||||
"prelude_points": attr.string_list(),
|
||||
"zip_safe": attr.bool(default = True),
|
||||
# FIXME: These are really toolchain parameters, probably.
|
||||
"compiler": attr.label(
|
||||
default = Label(DEFAULT_COMPILER),
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
),
|
||||
"shebang": attr.string(default = "/usr/bin/env %py3%"),
|
||||
"zip_safe": attr.bool(default = True),
|
||||
}
|
||||
|
||||
_zapp = rule(
|
||||
|
|
Loading…
Reference in a new issue