Skip to content

Commit

Permalink
Include symlinks and root_symlinks in Python ZIPs
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Mar 31, 2023
1 parent e97f62d commit d0dba4c
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ def _create_windows_exe_launcher(
use_default_shell_env = True,
)

def _map_zip_runfiles_symlink(prefix, symlink):
return "{}/{}={}".format(prefix, symlink.path, symlink.target_file.path)

def _map_zip_runfiles_root_symlink(symlink):
return _map_zip_runfiles_symlink(_ZIP_RUNFILES_DIRECTORY_NAME, symlink)

def _create_zip_file(ctx, *, output, original_nonzip_executable, executable_for_zip_file, runfiles):
workspace_name = ctx.workspace_name
legacy_external_runfiles = _py_builtins.get_legacy_external_runfiles(ctx)
Expand Down Expand Up @@ -370,6 +376,16 @@ def _create_zip_file(ctx, *, output, original_nonzip_executable, executable_for_
return None

manifest.add_all(runfiles.files, map_each = map_zip_runfiles, allow_closure = True)
manifest.add_all(
runfiles.symlinks,
map_each = lambda symlink: _map_zip_runfiles_symlink(
_ZIP_RUNFILES_DIRECTORY_NAME + "/" + workspace_name,
symlink,
),
allow_closure = True,
)
manifest.add_all(runfiles.root_symlinks, map_each = _map_zip_runfiles_root_symlink)

inputs = [executable_for_zip_file]
for artifact in runfiles.files.to_list():
# Don't include the original executable because it isn't used by the
Expand Down

0 comments on commit d0dba4c

Please sign in to comment.