From f48fdc08cec73e7440fc436935b8142054128bbc Mon Sep 17 00:00:00 2001 From: Shayan Hoshyari Date: Sat, 6 Dec 2025 02:06:08 -0800 Subject: [PATCH] Try using same strategy used for folders for the symlinks --- python/private/py_executable.bzl | 7 +------ python/private/venv_runfiles.bzl | 33 ++++++++++++++------------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/python/private/py_executable.bzl b/python/private/py_executable.bzl index 0a16e7690e..b9212af5eb 100644 --- a/python/private/py_executable.bzl +++ b/python/private/py_executable.bzl @@ -363,7 +363,7 @@ def _create_executable( [stage2_bootstrap] + ( venv.files_without_interpreter if venv else [] ), - ).merge(venv.lib_runfiles) + ) zip_main = _create_zip_main( ctx, stage2_bootstrap = stage2_bootstrap, @@ -637,11 +637,6 @@ def _create_venv(ctx, output_prefix, imports, runtime_details, add_runfiles_root venv, ), ), - # venv files for user library dependencies (files that are specific - # to the executable bootstrap and python runtime aren't here). - lib_runfiles = ctx.runfiles( - symlinks = venv_app_files.runfiles_symlinks, - ), ) def _map_each_identity(v): diff --git a/python/private/venv_runfiles.bzl b/python/private/venv_runfiles.bzl index eeedda4555..6761c99d64 100644 --- a/python/private/venv_runfiles.bzl +++ b/python/private/venv_runfiles.bzl @@ -33,9 +33,6 @@ def create_venv_app_files(ctx, deps, venv_dir_map): {type}`struct` with the following attributes: * {type}`list[File]` `venv_files` additional files created for the venv. - * {type}`dict[str, File]` `runfiles_symlinks` map intended for - the `runfiles.symlinks` argument. A map of main-repo - relative paths to File. """ # maps venv-relative path to the runfiles path it should point to @@ -49,31 +46,29 @@ def create_venv_app_files(ctx, deps, venv_dir_map): link_map = build_link_map(ctx, entries) venv_files = [] - runfiles_symlinks = {} for kind, kind_map in link_map.items(): base = venv_dir_map[kind] for venv_path, link_to in kind_map.items(): bin_venv_path = paths.join(base, venv_path) - if is_file(link_to): - symlink_from = "{}/{}".format(ctx.label.package, bin_venv_path) - runfiles_symlinks[symlink_from] = link_to - else: - venv_link = ctx.actions.declare_symlink(bin_venv_path) - venv_link_rf_path = runfiles_root_path(ctx, venv_link.short_path) - rel_path = relative_path( - # dirname is necessary because a relative symlink is relative to - # the directory the symlink resides within. - from_ = paths.dirname(venv_link_rf_path), - to = link_to, - ) - ctx.actions.symlink(output = venv_link, target_path = rel_path) - venv_files.append(venv_link) + # Just for demonstration purposes, + # there is definitely a better thing to do upstream that removeprefix("../") + link_to_path = link_to.short_path.removeprefix("../") if is_file(link_to) else link_to + + venv_link = ctx.actions.declare_symlink(bin_venv_path) + venv_link_rf_path = runfiles_root_path(ctx, venv_link.short_path) + rel_path = relative_path( + # dirname is necessary because a relative symlink is relative to + # the directory the symlink resides within. + from_ = paths.dirname(venv_link_rf_path), + to = link_to_path, + ) + ctx.actions.symlink(output = venv_link, target_path = rel_path) + venv_files.append(venv_link) return struct( venv_files = venv_files, - runfiles_symlinks = runfiles_symlinks, ) # Visible for testing