Skip to content

Commit 78eff68

Browse files
committed
fix zip_main hash calculation, was omitting inputs
1 parent ff00bd3 commit 78eff68

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

python/private/zipapp/py_zipapp_rule.bzl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _create_zipapp_main_py(ctx, py_runtime, py_executable, stage2_bootstrap, run
5555

5656
inputs = builders.DepsetBuilder()
5757
inputs.add(py_runtime.zip_main_template)
58-
_build_manifest(ctx, hash_files_manifest, runfiles, explicit_symlinks)
58+
_build_manifest(ctx, hash_files_manifest, runfiles, explicit_symlinks, inputs)
5959

6060
actions_run(
6161
ctx,
@@ -83,7 +83,7 @@ def _map_zip_root_symlinks(entry):
8383
def _map_explicit_symlinks(entry):
8484
return "symlink|" + entry.runfiles_path + "|" + entry.link_to_path
8585

86-
def _build_manifest(ctx, manifest, runfiles, explicit_symlinks, inputs = None):
86+
def _build_manifest(ctx, manifest, runfiles, explicit_symlinks, inputs):
8787
manifest.add_all(
8888
# NOTE: Accessing runfiles.empty_filenames materializes them. A lambda
8989
# is used to defer that.
@@ -97,12 +97,11 @@ def _build_manifest(ctx, manifest, runfiles, explicit_symlinks, inputs = None):
9797
manifest.add_all(runfiles.root_symlinks, map_each = _map_zip_root_symlinks)
9898
manifest.add_all(explicit_symlinks, map_each = _map_explicit_symlinks)
9999

100-
if inputs:
101-
inputs.add(runfiles.files)
102-
inputs.add([entry.target_file for entry in runfiles.symlinks.to_list()])
103-
inputs.add([entry.target_file for entry in runfiles.root_symlinks.to_list()])
104-
for entry in explicit_symlinks.to_list():
105-
inputs.add(entry.files)
100+
inputs.add(runfiles.files)
101+
inputs.add([entry.target_file for entry in runfiles.symlinks.to_list()])
102+
inputs.add([entry.target_file for entry in runfiles.root_symlinks.to_list()])
103+
for entry in explicit_symlinks.to_list():
104+
inputs.add(entry.files)
106105

107106
zip_repo_mapping_manifest = maybe_create_repo_mapping(
108107
ctx = ctx,
@@ -115,8 +114,7 @@ def _build_manifest(ctx, manifest, runfiles, explicit_symlinks, inputs = None):
115114
zip_repo_mapping_manifest.path,
116115
format = "rf-root-symlink|0|_repo_mapping|%s",
117116
)
118-
if inputs:
119-
inputs.add(zip_repo_mapping_manifest)
117+
inputs.add(zip_repo_mapping_manifest)
120118

121119
def _create_zip(ctx, py_runtime, py_executable, stage2_bootstrap):
122120
output = ctx.actions.declare_file(ctx.label.name + ".zip")

tools/private/zipapp/zipper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def create_zip(
186186
workspace_name,
187187
legacy_external_runfiles,
188188
runfiles_dir,
189-
pathsep,
189+
platform_pathsep,
190190
):
191191
compress_type = zipfile.ZIP_STORED if compress_level == 0 else zipfile.ZIP_DEFLATED
192192
zf_level = compress_level if compress_level != 0 else None
@@ -200,7 +200,7 @@ def create_zip(
200200
output_zip, "w", compress_type, allowZip64=True, compresslevel=zf_level
201201
) as zf:
202202
for entry in entries:
203-
_write_entry(zf, entry, compress_type, seen, pathsep)
203+
_write_entry(zf, entry, compress_type, seen, platform_pathsep)
204204

205205

206206
def main():

0 commit comments

Comments
 (0)