Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/3890.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(binaries) Fixed building of legacy zipapps on Windows execution platforms by
using a hermetic tool instead of host `cat`.
22 changes: 14 additions & 8 deletions python/private/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ load(":cc_helper.bzl", "cc_helper")
load(
":common.bzl",
"ExplicitSymlink",
"actions_run",
"collect_cc_info",
"collect_deps",
"collect_imports",
Expand Down Expand Up @@ -219,6 +220,10 @@ accepting arbitrary Python versions.
default = "//python/private:debugger_if_target_config",
providers = [PyInfo],
),
"_exe_zip_maker": lambda: attrb.Label(
cfg = "exec",
default = "//tools/private/zipapp:exe_zip_maker",
),
"_launcher": lambda: attrb.Label(
cfg = "target",
# NOTE: This is an executable, but is only used for Windows. It
Expand Down Expand Up @@ -1095,15 +1100,16 @@ def _create_executable_zip_file(
else:
ctx.actions.write(prelude, "#!/usr/bin/env python3\n")

ctx.actions.run_shell(
command = "cat {prelude} {zip} > {output}".format(
prelude = prelude.path,
zip = zip_file.path,
output = output.path,
),
inputs = [prelude, zip_file],
args = ctx.actions.args()
args.add(prelude)
args.add(zip_file)
args.add(output)
actions_run(
ctx,
executable = ctx.attr._exe_zip_maker,
arguments = [args],
inputs = depset([prelude, zip_file]),
outputs = [output],
use_default_shell_env = True,
mnemonic = "PyBuildExecutableZip",
progress_message = "Build Python zip executable: %{label}",
)
Expand Down