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 | |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 4 | py_runtime( |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 5 | name = "python3_runtime", |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 6 | files = [ |
| 7 | "runtime_binary.sh", |
| 8 | "@python_repo//:all_files", |
| 9 | ], |
| 10 | interpreter = "runtime_binary.sh", |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 11 | python_version = "PY3", |
| 12 | ) |
| 13 | |
| 14 | py_runtime_pair( |
| 15 | name = "py_runtime", |
| 16 | py2_runtime = None, |
| 17 | py3_runtime = ":python3_runtime", |
| 18 | ) |
| 19 | |
| 20 | toolchain( |
| 21 | name = "python_toolchain", |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 22 | exec_compatible_with = [ |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 23 | "@platforms//cpu:x86_64", |
| 24 | "@platforms//os:linux", |
| 25 | ], |
Philipp Schrader | 37fdbb6 | 2021-12-18 00:30:37 -0800 | [diff] [blame] | 26 | target_compatible_with = [ |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 27 | "@platforms//cpu:x86_64", |
| 28 | "@platforms//os:linux", |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 29 | "//tools/platforms/python:debian_bundled_python", |
Philipp Schrader | f198a15 | 2021-12-05 09:18:23 -0800 | [diff] [blame] | 30 | ], |
| 31 | toolchain = ":py_runtime", |
| 32 | toolchain_type = "@rules_python//python:toolchain_type", |
Brian Silverman | 6470f44 | 2018-08-05 12:08:16 -0700 | [diff] [blame] | 33 | ) |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 34 | |
| 35 | # Invoke this via "bazel run //tools/python:requirements.update". |
| 36 | compile_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. |
| 43 | # TODO(phil): Disable this if it's too flaky. |
| 44 | "requires-network", |
| 45 | ], |
| 46 | ) |
| 47 | |
| 48 | py_runtime( |
| 49 | name = "upstream_python3_runtime", |
| 50 | files = [ |
| 51 | "runtime_binary.sh", |
| 52 | "@python3_9_x86_64-unknown-linux-gnu//:files", |
| 53 | ], |
| 54 | interpreter = "runtime_binary.sh", |
| 55 | python_version = "PY3", |
| 56 | ) |
| 57 | |
| 58 | py_runtime_pair( |
| 59 | name = "upstream_py_runtime", |
| 60 | py2_runtime = None, |
| 61 | py3_runtime = ":upstream_python3_runtime", |
| 62 | ) |
| 63 | |
| 64 | toolchain( |
| 65 | name = "upstream_python_toolchain", |
| 66 | exec_compatible_with = [ |
| 67 | "@platforms//cpu:x86_64", |
| 68 | "@platforms//os:linux", |
| 69 | ], |
| 70 | target_compatible_with = [ |
| 71 | "@platforms//cpu:x86_64", |
| 72 | "@platforms//os:linux", |
| 73 | "//tools/platforms/python:upstream_bundled_python", |
| 74 | ], |
| 75 | toolchain = ":upstream_py_runtime", |
| 76 | toolchain_type = "@rules_python//python:toolchain_type", |
| 77 | ) |
Philipp Schrader | 868070a | 2022-09-06 22:51:13 -0700 | [diff] [blame^] | 78 | |
| 79 | py_binary( |
| 80 | name = "mirror_pip_packages", |
| 81 | srcs = ["mirror_pip_packages.py"], |
| 82 | deps = [ |
| 83 | "@pip//pkginfo", |
| 84 | "@pip//requests", |
| 85 | ], |
| 86 | ) |