Skip to content

Remove BASH_BIN in favor of referencing bash via /usr/bin/env #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions py/private/py_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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)

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -158,7 +156,6 @@ py_base = struct(
implementation = _py_binary_rule_impl,
attrs = _attrs,
toolchains = [
SH_TOOLCHAIN,
PY_TOOLCHAIN,
VENV_TOOLCHAIN,
],
Expand Down
5 changes: 1 addition & 4 deletions py/private/py_venv.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -121,7 +119,6 @@ _py_venv = rule(
),
},
toolchains = [
SH_TOOLCHAIN,
PY_TOOLCHAIN,
VENV_TOOLCHAIN,
],
Expand Down
4 changes: 3 additions & 1 deletion py/private/run.tmpl.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion py/private/venv.tmpl.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down