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. |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 43 | "requires-network", |
Philipp Schrader | 469a2f2 | 2022-10-29 14:25:58 -0700 | [diff] [blame] | 44 | # The test causes some packages' setup.py to be executed which can |
| 45 | # execute arbitrary code. Sometimes they look for compilers etc. That's |
| 46 | # not good for our hermeticity assumptions. Disable the test lock file |
| 47 | # test for now. |
| 48 | "manual", |
Philipp Schrader | 9e1b9bd | 2021-12-28 00:15:12 -0800 | [diff] [blame] | 49 | ], |
| 50 | ) |
| 51 | |
| 52 | py_runtime( |
| 53 | name = "upstream_python3_runtime", |
| 54 | files = [ |
| 55 | "runtime_binary.sh", |
| 56 | "@python3_9_x86_64-unknown-linux-gnu//:files", |
| 57 | ], |
| 58 | interpreter = "runtime_binary.sh", |
| 59 | python_version = "PY3", |
| 60 | ) |
| 61 | |
| 62 | py_runtime_pair( |
| 63 | name = "upstream_py_runtime", |
| 64 | py2_runtime = None, |
| 65 | py3_runtime = ":upstream_python3_runtime", |
| 66 | ) |
| 67 | |
| 68 | toolchain( |
| 69 | name = "upstream_python_toolchain", |
| 70 | exec_compatible_with = [ |
| 71 | "@platforms//cpu:x86_64", |
| 72 | "@platforms//os:linux", |
| 73 | ], |
| 74 | target_compatible_with = [ |
| 75 | "@platforms//cpu:x86_64", |
| 76 | "@platforms//os:linux", |
| 77 | "//tools/platforms/python:upstream_bundled_python", |
| 78 | ], |
| 79 | toolchain = ":upstream_py_runtime", |
| 80 | toolchain_type = "@rules_python//python:toolchain_type", |
| 81 | ) |
Philipp Schrader | 868070a | 2022-09-06 22:51:13 -0700 | [diff] [blame] | 82 | |
| 83 | py_binary( |
| 84 | name = "mirror_pip_packages", |
| 85 | srcs = ["mirror_pip_packages.py"], |
| 86 | deps = [ |
| 87 | "@pip//pkginfo", |
| 88 | "@pip//requests", |
| 89 | ], |
| 90 | ) |