Skip to content

Commit

Permalink
python: Fixed bootstrap template not being passed to py_binary from p…
Browse files Browse the repository at this point in the history
…y_runtime on bazel latest

This PR fixes a small bug where the bootstrap template runtime file was not being passed to Py Binary. This broke the bootstrap template feature on bazel latest authored in #16806

Closes #18103.

PiperOrigin-RevId: 525042380
Change-Id: I8b8a200634eb98e156b4d8ba6b2e5baef5d06c73
  • Loading branch information
ankit-agarwal1999 authored and Copybara-Service committed Apr 18, 2023
1 parent 5848524 commit 1840ad0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ 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,",
" attrs = {",
" '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(
Expand All @@ -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',",
Expand Down

0 comments on commit 1840ad0

Please sign in to comment.