Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include symlinks and root_symlinks in Python ZIPs #17942

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
rickeylev marked this conversation as resolved.
Show resolved Hide resolved
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