From f91f0024827c18984aa6e090567c9fef73a6c99f Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Sat, 2 Mar 2024 15:55:15 -0800 Subject: [PATCH] chore: rebase --- MODULE.bazel.orig | 75 ---------------------------------------- py/private/py_binary.bzl | 5 +-- py/private/py_venv.bzl | 4 +-- py/private/run.tmpl.sh | 4 ++- py/private/venv.tmpl.sh | 4 ++- 5 files changed, 8 insertions(+), 84 deletions(-) delete mode 100644 MODULE.bazel.orig diff --git a/MODULE.bazel.orig b/MODULE.bazel.orig deleted file mode 100644 index 43a81619..00000000 --- a/MODULE.bazel.orig +++ /dev/null @@ -1,75 +0,0 @@ -"aspect-build/rules_py" - -module( - name = "aspect_rules_py", - compatibility_level = 1, - version = "0.0.0", -) - -# Lower-bound versions of direct dependencies. -# When bumping, add a comment explaining what's required from the newer release. -bazel_dep(name = "aspect_bazel_lib", version = "1.40.0") -bazel_dep(name = "bazel_skylib", version = "1.4.2") -bazel_dep(name = "rules_python", version = "0.29.0") -bazel_dep(name = "platforms", version = "0.0.7") - -tools = use_extension("//py:extensions.bzl", "py_tools") -tools.rules_py_tools() -use_repo(tools, "rules_py_tools") - -register_toolchains( - "@rules_py_tools//:all", - - # Register the "from source" toolchains last, so there's no accidental dependency on Rust - # For manual testing: comment these out to force use of pre-built binaries. - "@aspect_rules_py//py/private/toolchain/venv/...", - "@aspect_rules_py//py/private/toolchain/unpack/...", -) - -# To allow Rust binaries in /py/tools to be built from source -# NOTE: when publishing to BCR, we patch these to be dev_dependency, as we publish pre-built binaries -# along with our releases. - -bazel_dep( - name = "rules_rust", - version = "0.38.0", - # In released versions: dev_dependency = True -) - -rust = use_extension( - "@rules_rust//rust:extensions.bzl", - "rust", - # In released versions: dev_dependency = True -) - -rust.toolchain( - edition = "2021", - versions = ["1.74.1"], -) -use_repo(rust, "rust_toolchains") - -register_toolchains( - "@rust_toolchains//:all", - # In released versions: dev_dependency = True -) - -crate = use_extension( - "@rules_rust//crate_universe:extension.bzl", - "crate", - # In released versions: dev_dependency = True -) - -crate.from_cargo( - name = "crate_index", - cargo_lockfile = "//:Cargo.lock", - # Apparently not needed under bzlmod? - # lockfile = "//:Cargo.Bazel.lock", - manifests = [ - "//:Cargo.toml", - "//py/tools/py:Cargo.toml", - "//py/tools/venv_bin:Cargo.toml", - "//py/tools/unpack_bin:Cargo.toml", - ], -) - -use_repo(crate, "crate_index") diff --git a/py/private/py_binary.bzl b/py/private/py_binary.bzl index 8467c269..8acfd265 100644 --- a/py/private/py_binary.bzl +++ b/py/private/py_binary.bzl @@ -4,7 +4,7 @@ load("@aspect_bazel_lib//lib:paths.bzl", "BASH_RLOCATION_FUNCTION", "to_rlocatio load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations", "expand_variables") load("//py/private:py_library.bzl", _py_library = "py_library_utils") load("//py/private:py_semantics.bzl", _py_semantics = "semantics") -load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "SH_TOOLCHAIN", "VENV_TOOLCHAIN") +load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "VENV_TOOLCHAIN") def _dict_to_exports(env): return [ @@ -13,7 +13,6 @@ def _dict_to_exports(env): ] def _py_binary_rule_impl(ctx): - sh_toolchain = ctx.toolchains[SH_TOOLCHAIN] venv_toolchain = ctx.toolchains[VENV_TOOLCHAIN] py_toolchain = _py_semantics.resolve_toolchain(ctx) @@ -67,7 +66,6 @@ def _py_binary_rule_impl(ctx): template = ctx.file._run_tmpl, output = executable_launcher, substitutions = { - "{{SHELL_BIN}}": sh_toolchain.path, "{{BASH_RLOCATION_FN}}": BASH_RLOCATION_FUNCTION, "{{INTERPRETER_FLAGS}}": " ".join(py_toolchain.flags), "{{VENV_TOOL}}": to_rlocation_path(ctx, venv_toolchain.bin), @@ -158,7 +156,6 @@ py_base = struct( implementation = _py_binary_rule_impl, attrs = _attrs, toolchains = [ - SH_TOOLCHAIN, PY_TOOLCHAIN, VENV_TOOLCHAIN, ], diff --git a/py/private/py_venv.bzl b/py/private/py_venv.bzl index bbde295c..bb0d9d13 100644 --- a/py/private/py_venv.bzl +++ b/py/private/py_venv.bzl @@ -5,10 +5,9 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("//py/private:providers.bzl", "PyVirtualInfo") load("//py/private:py_library.bzl", _py_library = "py_library_utils") load("//py/private:py_semantics.bzl", _py_semantics = "semantics") -load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "SH_TOOLCHAIN", "VENV_TOOLCHAIN") +load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "VENV_TOOLCHAIN") def _py_venv_rule_imp(ctx): - sh_toolchain = ctx.toolchains[SH_TOOLCHAIN] venv_toolchain = ctx.toolchains[VENV_TOOLCHAIN] py_toolchain = _py_semantics.resolve_toolchain(ctx) @@ -41,7 +40,6 @@ def _py_venv_rule_imp(ctx): template = ctx.file._venv_tmpl, output = executable_launcher, substitutions = { - "{{SHELL_BIN}}": sh_toolchain.path, "{{BASH_RLOCATION_FN}}": BASH_RLOCATION_FUNCTION, "{{INTERPRETER_FLAGS}}": " ".join(py_toolchain.flags), "{{VENV_TOOL}}": to_rlocation_path(ctx, venv_toolchain.bin), diff --git a/py/private/run.tmpl.sh b/py/private/run.tmpl.sh index 9ff44cbf..dac92423 100644 --- a/py/private/run.tmpl.sh +++ b/py/private/run.tmpl.sh @@ -1,4 +1,6 @@ -#!{{SHELL_BIN}} +#!/usr/bin/env bash +# NB: we don't use a path from @bazel_tools//tools/sh:toolchain_type because that's configured for the exec +# configuration, while this script executes in the target configuration at runtime. {{BASH_RLOCATION_FN}} runfiles_export_envvars diff --git a/py/private/venv.tmpl.sh b/py/private/venv.tmpl.sh index 2be9f442..92936914 100644 --- a/py/private/venv.tmpl.sh +++ b/py/private/venv.tmpl.sh @@ -1,4 +1,6 @@ -#!{{SHELL_BIN}} +#!/usr/bin/env bash +# NB: we don't use a path from @bazel_tools//tools/sh:toolchain_type because that's configured for the exec +# configuration, while this script executes in the target configuration at runtime. {{BASH_RLOCATION_FN}} runfiles_export_envvars