blob: 1835e0da65b3dd0f996ffae668e81a72c4926c74 [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",
Austin Schuhea5f0a72024-09-02 15:02:36 -07007 extra_args = [
8 # Make it so we can depend on setuptools.
9 "--allow-unsafe",
10 ],
Philipp Schrader01535ee2023-01-08 13:19:03 -080011 requirements_in = "requirements.txt",
12 requirements_txt = "requirements.lock.txt",
13 tags = [
14 # The test pings pypi.org to make sure that the lock file matches the
15 # requirements file.
16 "requires-network",
17 # The test causes some packages' setup.py to be executed which can
18 # execute arbitrary code. Sometimes they look for compilers etc. That's
19 # not good for our hermeticity assumptions. Disable the test lock file
20 # test for now.
21 "manual",
22 ],
23)
24
Philipp Schrader8ac22f32023-12-30 17:37:15 -080025# This binary is intended to run the `requirements.update` target in a Docker
26# container. This is primarily intended for reproducibility. See README.md.
27sh_binary(
28 name = "update_helper",
29 srcs = ["update_helper.sh"],
30 data = [
31 "update_helper_files/Dockerfile",
32 ],
33 deps = [
34 "@bazel_tools//tools/bash/runfiles",
35 ],
36)
37
Brian Silverman6470f442018-08-05 12:08:16 -070038py_runtime(
Philipp Schraderf198a152021-12-05 09:18:23 -080039 name = "python3_runtime",
Brian Silverman6470f442018-08-05 12:08:16 -070040 files = [
41 "runtime_binary.sh",
Philipp Schrader01535ee2023-01-08 13:19:03 -080042 "@python3_9_x86_64-unknown-linux-gnu//:files",
Brian Silverman6470f442018-08-05 12:08:16 -070043 ],
44 interpreter = "runtime_binary.sh",
Philipp Schraderf198a152021-12-05 09:18:23 -080045 python_version = "PY3",
46)
47
48py_runtime_pair(
49 name = "py_runtime",
50 py2_runtime = None,
51 py3_runtime = ":python3_runtime",
52)
53
54toolchain(
55 name = "python_toolchain",
Philipp Schrader37fdbb62021-12-18 00:30:37 -080056 exec_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080057 "@platforms//cpu:x86_64",
58 "@platforms//os:linux",
59 ],
Philipp Schrader37fdbb62021-12-18 00:30:37 -080060 target_compatible_with = [
Philipp Schraderf198a152021-12-05 09:18:23 -080061 "@platforms//cpu:x86_64",
62 "@platforms//os:linux",
63 ],
64 toolchain = ":py_runtime",
65 toolchain_type = "@rules_python//python:toolchain_type",
Brian Silverman6470f442018-08-05 12:08:16 -070066)
Philipp Schrader9e1b9bd2021-12-28 00:15:12 -080067
Philipp Schrader868070a2022-09-06 22:51:13 -070068py_binary(
69 name = "mirror_pip_packages",
70 srcs = ["mirror_pip_packages.py"],
71 deps = [
72 "@pip//pkginfo",
73 "@pip//requests",
74 ],
75)