blob: 78203bc2a6f3973417fe0551a4d40e73b360e712 [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.
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080043 "requires-network",
Philipp Schrader469a2f22022-10-29 14:25:58 -070044 # The test causes some packages' setup.py to be executed which can
45 # execute arbitrary code. Sometimes they look for compilers etc. That's
46 # not good for our hermeticity assumptions. Disable the test lock file
47 # test for now.
48 "manual",
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080049 ],
50)
51
52py_runtime(
53 name = "upstream_python3_runtime",
54 files = [
55 "runtime_binary.sh",
56 "@python3_9_x86_64-unknown-linux-gnu//:files",
57 ],
58 interpreter = "runtime_binary.sh",
59 python_version = "PY3",
60)
61
62py_runtime_pair(
63 name = "upstream_py_runtime",
64 py2_runtime = None,
65 py3_runtime = ":upstream_python3_runtime",
66)
67
68toolchain(
69 name = "upstream_python_toolchain",
70 exec_compatible_with = [
71 "@platforms//cpu:x86_64",
72 "@platforms//os:linux",
73 ],
74 target_compatible_with = [
75 "@platforms//cpu:x86_64",
76 "@platforms//os:linux",
77 "//tools/platforms/python:upstream_bundled_python",
78 ],
79 toolchain = ":upstream_py_runtime",
80 toolchain_type = "@rules_python//python:toolchain_type",
81)
Philipp Schrader868070a2022-09-06 22:51:13 -070082
83py_binary(
84 name = "mirror_pip_packages",
85 srcs = ["mirror_pip_packages.py"],
86 deps = [
87 "@pip//pkginfo",
88 "@pip//requests",
89 ],
90)