diff --git a/src/main/starlark/builtins_bzl/common/python/py_executable_bazel.bzl b/src/main/starlark/builtins_bzl/common/python/py_executable_bazel.bzl index 6969cbdb227d68..09b8916db13e32 100644 --- a/src/main/starlark/builtins_bzl/common/python/py_executable_bazel.bzl +++ b/src/main/starlark/builtins_bzl/common/python/py_executable_bazel.bzl @@ -290,11 +290,13 @@ def _expand_bootstrap_template( if runtime: shebang = runtime.stub_shebang + template = runtime.bootstrap_template else: shebang = DEFAULT_STUB_SHEBANG + template = ctx.file._bootstrap_template ctx.actions.expand_template( - template = ctx.file._bootstrap_template, + template = template, output = output, substitutions = { "%shebang%": shebang, diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java index c6b4d68affb3ff..5231839f249850 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java @@ -120,7 +120,8 @@ public void runtimeSandwich() throws Exception { " return [PyRuntimeInfo(", " interpreter = ctx.file.interpreter,", " files = depset(direct = ctx.files.files, transitive=[info.files]),", - " python_version = info.python_version)]", + " python_version = info.python_version,", + " bootstrap_template = ctx.file.bootstrap_template)]", "", "userruntime = rule(", " implementation = _userruntime_impl,", @@ -128,6 +129,7 @@ public void runtimeSandwich() throws Exception { " 'runtime': attr.label(),", " 'interpreter': attr.label(allow_single_file=True),", " 'files': attr.label_list(allow_files=True),", + " 'bootstrap_template': attr.label(allow_single_file=True),", " },", ")"); scratch.file( @@ -148,6 +150,7 @@ public void runtimeSandwich() throws Exception { " runtime = ':pyruntime',", " interpreter = ':userintr',", " files = ['userdata.txt'],", + " bootstrap_template = 'bootstrap.txt',", ")", "py_runtime_pair(", " name = 'userruntime_pair',",