Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 1 | load("@rules_python//python:defs.bzl", "py_runtime_pair") |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 2 | load("@rules_python//python:pip.bzl", "compile_pip_requirements") |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 3 | |
Philipp Schrader | 01535ee | 2023-01-08 13:19:03 -0800 | [diff] [blame] | 4 | # Invoke this via "bazel run //tools/python:requirements.update". |
| 5 | compile_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 Schrader | 8ac22f3 | 2023-12-30 17:37:15 -0800 | [diff] [blame^] | 21 | # This binary is intended to run the `requirements.update` target in a Docker |
| 22 | # container. This is primarily intended for reproducibility. See README.md. |
| 23 | sh_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 Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 34 | py_runtime( |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 35 | name = "python3_runtime", |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 36 | files = [ |
| 37 | "runtime_binary.sh", |
Philipp Schrader | 01535ee | 2023-01-08 13:19:03 -0800 | [diff] [blame] | 38 | "@python3_9_x86_64-unknown-linux-gnu//:files", |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 39 | ], |
| 40 | interpreter = "runtime_binary.sh", |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 41 | python_version = "PY3", |
| 42 | ) |
| 43 | |
| 44 | py_runtime_pair( |
| 45 | name = "py_runtime", |
| 46 | py2_runtime = None, |
| 47 | py3_runtime = ":python3_runtime", |
| 48 | ) |
| 49 | |
| 50 | toolchain( |
| 51 | name = "python_toolchain", |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 52 | exec_compatible_with = [ |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 53 | "@platforms//cpu:x86_64", |
| 54 | "@platforms//os:linux", |
| 55 | ], |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 56 | target_compatible_with = [ |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 57 | "@platforms//cpu:x86_64", |
| 58 | "@platforms//os:linux", |
| 59 | ], |
| 60 | toolchain = ":py_runtime", |
| 61 | toolchain_type = "@rules_python//python:toolchain_type", |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 62 | ) |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 63 | |
Philipp Schrader | 868070a | 2022-09-06 22:51:13 -0700 | [diff] [blame] | 64 | py_binary( |
| 65 | name = "mirror_pip_packages", |
| 66 | srcs = ["mirror_pip_packages.py"], |
| 67 | deps = [ |
| 68 | "@pip//pkginfo", |
| 69 | "@pip//requests", |
| 70 | ], |
| 71 | ) |