blob: 40698ef9773ac394f308edab6d549d4eb434c30b [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
Philipp Schrader8ac22f32023-12-30 17:37:15 -080021# This binary is intended to run the `requirements.update` target in a Docker
22# container. This is primarily intended for reproducibility. See README.md.
23sh_binary(
24 name = "update_helper",
25 srcs = ["update_helper.sh"],
26 data = [
27 "update_helper_files/Dockerfile",
28 ],
29 deps = [
30 "@bazel_tools//tools/bash/runfiles",
31 ],
32)
33
Brian Silverman6470f442018-08-05 12:08:16 -070034py_runtime(
Philipp Schraderf198a152021-12-05 09:18:23 -080035 name = "python3_runtime",
Brian Silverman6470f442018-08-05 12:08:16 -070036 files = [
37 "runtime_binary.sh",
Philipp Schrader01535ee2023-01-08 13:19:03 -080038 "@python3_9_x86_64-unknown-linux-gnu//:files",
Brian Silverman6470f442018-08-05 12:08:16 -070039 ],
40 interpreter = "runtime_binary.sh",
Philipp Schraderf198a152021-12-05 09:18:23 -080041 python_version = "PY3",
42)
43
44py_runtime_pair(
45 name = "py_runtime",
46 py2_runtime = None,
47 py3_runtime = ":python3_runtime",
48)
49
50toolchain(
51 name = "python_toolchain",
Philipp Schrader37fdbb62021-12-18 00:30:37 -080052 exec_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080053 "@platforms//cpu:x86_64",
54 "@platforms//os:linux",
55 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -080056 target_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080057 "@platforms//cpu:x86_64",
58 "@platforms//os:linux",
59 ],
60 toolchain = ":py_runtime",
61 toolchain_type = "@rules_python//python:toolchain_type",
Brian Silverman6470f442018-08-05 12:08:16 -070062)
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080063
Philipp Schrader868070a2022-09-06 22:51:13 -070064py_binary(
65 name = "mirror_pip_packages",
66 srcs = ["mirror_pip_packages.py"],
67 deps = [
68 "@pip//pkginfo",
69 "@pip//requests",
70 ],
71)