bazel-lib
bazel-lib copied to clipboard
[FR]: Allow additional tools to be passed to `run_binary`
What is the current behavior?
Currently the arguments to run_binary include tool which is used to specify the tool which will be executed during the build. This argument is used in variable expansion in env and args.
However, if you want to use another tool in env or args, it's not possible.
Describe the feature
Add tools to run_binary. This attr is used in variable expansion, but the tools are otherwise not executed
I'm curious to see an example of what this usage looks like. Could you paste some example?
I have something that looks like this:
py_console_script_binary(
name = "poetry",
pkg = "@poetry_deps//poetry",
deps = [
"@poetry_deps//poetry_plugin_bundle:poetry_plugin_bundle",
],
)
sh_binary(
name = "poetry_test",
srcs = [":py_wrapper.sh"],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
run_binary(
name = "poetry_venv",
srcs = [
"... stuff ...",
],
env = {
"BIN": "$(location :poetry)",
},
tool = ":poetry_test",
tools = [ ":poetry" ],
outs = ["poetry_venv.tar.gz"],
visibility = ["//visibility:public"],
tags = ["requires-network"],
)
py_wrapper.sh executed BIN, and the poetry target has multiple files in it, so I can't just put it in srcs to use location on. An alternative might be to find it through runfiles somehow, but that seems overly complicated, and I'd still have the location problem when using the runfiles shim