From 9e882deb8ba30707da69410f119a5f18002cab52 Mon Sep 17 00:00:00 2001 From: Vasilii Muravev Date: Wed, 20 Nov 2024 15:16:10 +0100 Subject: [PATCH] feat: add ability to pass user flags to python interpreter --- py/private/py_binary.bzl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py/private/py_binary.bzl b/py/private/py_binary.bzl index cd9cad45..f0e59f07 100644 --- a/py/private/py_binary.bzl +++ b/py/private/py_binary.bzl @@ -68,7 +68,7 @@ def _py_binary_rule_impl(ctx): output = executable_launcher, substitutions = { "{{BASH_RLOCATION_FN}}": BASH_RLOCATION_FUNCTION, - "{{INTERPRETER_FLAGS}}": " ".join(py_toolchain.flags), + "{{INTERPRETER_FLAGS}}": " ".join(py_toolchain.flags + ctx.attr.interpreter_args), "{{VENV_TOOL}}": to_rlocation_path(ctx, venv_toolchain.bin), "{{ARG_COLLISION_STRATEGY}}": ctx.attr.package_collisions, "{{ARG_PYTHON}}": to_rlocation_path(ctx, py_toolchain.python) if py_toolchain.runfiles_interpreter else py_toolchain.python.path, @@ -149,6 +149,10 @@ A collision can occour when multiple packages providing the same file are instal default = "error", values = ["error", "warning", "ignore"], ), + "interpreter_args": attr.string_list( + doc = "Additional arguments to pass to the Python interpreter.", + default = [], + ), "_run_tmpl": attr.label( allow_single_file = True, default = "//py/private:run.tmpl.sh",