blob: 37101f54a70b3639e6fa0fc60fe255933eb3737a [file] [log] [blame]
Philipp Schraderf198a152021-12-05 09:18:23 -08001load("@rules_python//python:defs.bzl", "py_runtime_pair")
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -08002load("@rules_python//python:pip.bzl", "compile_pip_requirements")
Philipp Schraderf198a152021-12-05 09:18:23 -08003
Brian Silverman6470f442018-08-05 12:08:16 -07004py_runtime(
Philipp Schraderf198a152021-12-05 09:18:23 -08005 name = "python3_runtime",
Brian Silverman6470f442018-08-05 12:08:16 -07006 files = [
7 "runtime_binary.sh",
8 "@python_repo//:all_files",
9 ],
10 interpreter = "runtime_binary.sh",
Philipp Schraderf198a152021-12-05 09:18:23 -080011 python_version = "PY3",
12)
13
14py_runtime_pair(
15 name = "py_runtime",
16 py2_runtime = None,
17 py3_runtime = ":python3_runtime",
18)
19
20toolchain(
21 name = "python_toolchain",
Philipp Schrader37fdbb62021-12-18 00:30:37 -080022 exec_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080023 "@platforms//cpu:x86_64",
24 "@platforms//os:linux",
25 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -080026 target_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080027 "@platforms//cpu:x86_64",
28 "@platforms//os:linux",
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080029 "//tools/platforms/python:debian_bundled_python",
Philipp Schraderf198a152021-12-05 09:18:23 -080030 ],
31 toolchain = ":py_runtime",
32 toolchain_type = "@rules_python//python:toolchain_type",
Brian Silverman6470f442018-08-05 12:08:16 -070033)
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080034
35# Invoke this via "bazel run //tools/python:requirements.update".
36compile_pip_requirements(
37 name = "requirements",
38 requirements_in = "requirements.txt",
39 requirements_txt = "requirements.lock.txt",
40 tags = [
41 # The test pings pypi.org to make sure that the lock file matches the
42 # requirements file.
43 # TODO(phil): Disable this if it's too flaky.
44 "requires-network",
45 ],
46)
47
48py_runtime(
49 name = "upstream_python3_runtime",
50 files = [
51 "runtime_binary.sh",
52 "@python3_9_x86_64-unknown-linux-gnu//:files",
53 ],
54 interpreter = "runtime_binary.sh",
55 python_version = "PY3",
56)
57
58py_runtime_pair(
59 name = "upstream_py_runtime",
60 py2_runtime = None,
61 py3_runtime = ":upstream_python3_runtime",
62)
63
64toolchain(
65 name = "upstream_python_toolchain",
66 exec_compatible_with = [
67 "@platforms//cpu:x86_64",
68 "@platforms//os:linux",
69 ],
70 target_compatible_with = [
71 "@platforms//cpu:x86_64",
72 "@platforms//os:linux",
73 "//tools/platforms/python:upstream_bundled_python",
74 ],
75 toolchain = ":upstream_py_runtime",
76 toolchain_type = "@rules_python//python:toolchain_type",
77)