diff --git a/news/3890.fixed.md b/news/3890.fixed.md new file mode 100644 index 0000000000..59cd5fc5ca --- /dev/null +++ b/news/3890.fixed.md @@ -0,0 +1,2 @@ +(binaries) Fixed building of legacy zipapps on Windows execution platforms by +using a hermetic tool instead of host `cat`. diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index c519af8c09..242b09344e 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -38,6 +38,7 @@ load(":cc_helper.bzl", "cc_helper") load( ":common.bzl", "ExplicitSymlink", + "actions_run", "collect_cc_info", "collect_deps", "collect_imports", @@ -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 @@ -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}", )