|
| 1 | +"aspect-build/rules_py" |
| 2 | + |
| 3 | +module( |
| 4 | + name = "aspect_rules_py", |
| 5 | + version = "1.4.0", |
| 6 | + compatibility_level = 1, |
| 7 | +) |
| 8 | + |
| 9 | +# Lower-bound versions of direct dependencies. |
| 10 | +# When bumping, add a comment explaining what's required from the newer release. |
| 11 | + |
| 12 | +# py_image_layer requires 2.x for the `tar` rule. |
| 13 | +# py_image_layer needs compute_unused_inputs attribute |
| 14 | +# py_image_layer needs repo_mapping fix. |
| 15 | +bazel_dep(name = "aspect_bazel_lib", version = "2.16.0") |
| 16 | +bazel_dep(name = "bazel_skylib", version = "1.4.2") |
| 17 | +bazel_dep(name = "rules_python", version = "0.29.0") |
| 18 | +bazel_dep(name = "platforms", version = "0.0.7") |
| 19 | + |
| 20 | +bazel_lib = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains") |
| 21 | +bazel_lib.expand_template() |
| 22 | + |
| 23 | +# Custom python version for testing only |
| 24 | +python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True) |
| 25 | +python.toolchain( |
| 26 | + is_default = False, |
| 27 | + python_version = "3.8.12", |
| 28 | +) |
| 29 | + |
| 30 | +tools = use_extension("//py:extensions.bzl", "py_tools") |
| 31 | +tools.rules_py_tools() |
| 32 | +use_repo(tools, "rules_py_tools") |
| 33 | +use_repo(tools, "rules_py_pex_2_3_1") |
| 34 | + |
| 35 | +register_toolchains( |
| 36 | + "@rules_py_tools//:all", |
| 37 | + |
| 38 | + # Register the "from source" toolchains last, so there's no accidental dependency on Rust |
| 39 | + # For manual testing: comment these out to force use of pre-built binaries. |
| 40 | + "@aspect_rules_py//py/private/toolchain/venv/...", |
| 41 | + "@aspect_rules_py//py/private/toolchain/unpack/...", |
| 42 | +) |
| 43 | + |
| 44 | +# To allow Rust binaries in /py/tools to be built from source |
| 45 | +# NOTE: when publishing to BCR, we patch these to be dev_dependency, as we publish pre-built binaries |
| 46 | +# along with our releases. |
| 47 | + |
| 48 | +bazel_dep( |
| 49 | + name = "rules_rust", |
| 50 | + version = "0.53.0", |
| 51 | + dev_dependency = True, |
| 52 | +) |
| 53 | + |
| 54 | +rust = use_extension( |
| 55 | + "@rules_rust//rust:extensions.bzl", |
| 56 | + "rust", |
| 57 | + dev_dependency = True, |
| 58 | +) |
| 59 | +rust.toolchain( |
| 60 | + edition = "2021", |
| 61 | + versions = ["1.81.0"], |
| 62 | +) |
| 63 | +use_repo(rust, "rust_toolchains") |
| 64 | + |
| 65 | +register_toolchains( |
| 66 | + "@rust_toolchains//:all", |
| 67 | + dev_dependency = True, |
| 68 | +) |
| 69 | + |
| 70 | +crate = use_extension( |
| 71 | + "@rules_rust//crate_universe:extension.bzl", |
| 72 | + "crate", |
| 73 | + dev_dependency = True, |
| 74 | +) |
| 75 | +crate.from_cargo( |
| 76 | + name = "crate_index", |
| 77 | + cargo_lockfile = "//:Cargo.lock", |
| 78 | + # Apparently not needed under bzlmod? |
| 79 | + # lockfile = "//:Cargo.Bazel.lock", |
| 80 | + manifests = [ |
| 81 | + "//:Cargo.toml", |
| 82 | + "//py/tools/py:Cargo.toml", |
| 83 | + "//py/tools/unpack_bin:Cargo.toml", |
| 84 | + "//py/tools/venv_bin:Cargo.toml", |
| 85 | + "//py/tools/venv_shim:Cargo.toml", |
| 86 | + ], |
| 87 | +) |
| 88 | +use_repo(crate, "crate_index") |
| 89 | + |
| 90 | +# For building test images with py_image_layer |
| 91 | +bazel_dep(name = "container_structure_test", version = "1.19.1", dev_dependency = True) |
| 92 | +bazel_dep(name = "rules_oci", version = "2.0.1", dev_dependency = True) |
| 93 | + |
| 94 | +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci", dev_dependency = True) |
| 95 | +oci.pull( |
| 96 | + name = "ubuntu", |
| 97 | + digest = "sha256:80dd3c3b9c6cecb9f1667e9290b3bc61b78c2678c02cbdae5f0fea92cc6734ab", |
| 98 | + image = "ubuntu", |
| 99 | + platforms = [ |
| 100 | + "linux/arm64/v8", |
| 101 | + "linux/amd64", |
| 102 | + ], |
| 103 | + tag = "latest", |
| 104 | +) |
| 105 | +use_repo(oci, "ubuntu", "ubuntu_linux_amd64", "ubuntu_linux_arm64_v8") |
0 commit comments