Skip to content

Commit 4aa0f58

Browse files
feat: add ability to pass user flags to python interpreter
1 parent eb9e0f2 commit 4aa0f58

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

docs/py_binary.md

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/py_test.md

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py/private/py_binary.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _py_binary_rule_impl(ctx):
6868
output = executable_launcher,
6969
substitutions = {
7070
"{{BASH_RLOCATION_FN}}": BASH_RLOCATION_FUNCTION,
71-
"{{INTERPRETER_FLAGS}}": " ".join(py_toolchain.flags),
71+
"{{INTERPRETER_FLAGS}}": " ".join(py_toolchain.flags + ctx.attr.interpreter_options),
7272
"{{VENV_TOOL}}": to_rlocation_path(ctx, venv_toolchain.bin),
7373
"{{ARG_COLLISION_STRATEGY}}": ctx.attr.package_collisions,
7474
"{{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
149149
default = "error",
150150
values = ["error", "warning", "ignore"],
151151
),
152+
"interpreter_options": attr.string_list(
153+
doc = "Additional options to pass to the Python interpreter in addition to -B and -I passed by rules_py",
154+
default = [],
155+
),
152156
"_run_tmpl": attr.label(
153157
allow_single_file = True,
154158
default = "//py/private:run.tmpl.sh",

0 commit comments

Comments
 (0)