blob: 8e410e5c22c8b6b91779e5f2b9995cf9dfa6ecfe [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
Philipp Schrader01535ee2023-01-08 13:19:03 -08004# Invoke this via "bazel run //tools/python:requirements.update".
5compile_pip_requirements(
6 name = "requirements",
7 requirements_in = "requirements.txt",
8 requirements_txt = "requirements.lock.txt",
9 tags = [
10 # The test pings pypi.org to make sure that the lock file matches the
11 # requirements file.
12 "requires-network",
13 # The test causes some packages' setup.py to be executed which can
14 # execute arbitrary code. Sometimes they look for compilers etc. That's
15 # not good for our hermeticity assumptions. Disable the test lock file
16 # test for now.
17 "manual",
18 ],
19)
20
Brian Silverman6470f442018-08-05 12:08:16 -070021py_runtime(
Philipp Schraderf198a152021-12-05 09:18:23 -080022 name = "python3_runtime",
Brian Silverman6470f442018-08-05 12:08:16 -070023 files = [
24 "runtime_binary.sh",
Philipp Schrader01535ee2023-01-08 13:19:03 -080025 "@python3_9_x86_64-unknown-linux-gnu//:files",
Brian Silverman6470f442018-08-05 12:08:16 -070026 ],
27 interpreter = "runtime_binary.sh",
Philipp Schraderf198a152021-12-05 09:18:23 -080028 python_version = "PY3",
29)
30
31py_runtime_pair(
32 name = "py_runtime",
33 py2_runtime = None,
34 py3_runtime = ":python3_runtime",
35)
36
37toolchain(
38 name = "python_toolchain",
Philipp Schrader37fdbb62021-12-18 00:30:37 -080039 exec_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080040 "@platforms//cpu:x86_64",
41 "@platforms//os:linux",
42 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -080043 target_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080044 "@platforms//cpu:x86_64",
45 "@platforms//os:linux",
46 ],
47 toolchain = ":py_runtime",
48 toolchain_type = "@rules_python//python:toolchain_type",
Brian Silverman6470f442018-08-05 12:08:16 -070049)
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080050
Philipp Schrader868070a2022-09-06 22:51:13 -070051py_binary(
52 name = "mirror_pip_packages",
53 srcs = ["mirror_pip_packages.py"],
54 deps = [
55 "@pip//pkginfo",
56 "@pip//requests",
57 ],
58)