Skip to content

Commit ff56c1d

Browse files
author
Shayan Hoshyari
committed
Try using same strategy used for folders for the symlinks
1 parent 759f5da commit ff56c1d

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

python/private/py_executable.bzl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def _create_executable(
363363
[stage2_bootstrap] + (
364364
venv.files_without_interpreter if venv else []
365365
),
366-
).merge(venv.lib_runfiles)
366+
)
367367
zip_main = _create_zip_main(
368368
ctx,
369369
stage2_bootstrap = stage2_bootstrap,
@@ -637,11 +637,6 @@ def _create_venv(ctx, output_prefix, imports, runtime_details, add_runfiles_root
637637
venv,
638638
),
639639
),
640-
# venv files for user library dependencies (files that are specific
641-
# to the executable bootstrap and python runtime aren't here).
642-
lib_runfiles = ctx.runfiles(
643-
symlinks = venv_app_files.runfiles_symlinks,
644-
),
645640
)
646641

647642
def _map_each_identity(v):

python/private/venv_runfiles.bzl

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def create_venv_app_files(ctx, deps, venv_dir_map):
3333
{type}`struct` with the following attributes:
3434
* {type}`list[File]` `venv_files` additional files created for
3535
the venv.
36-
* {type}`dict[str, File]` `runfiles_symlinks` map intended for
37-
the `runfiles.symlinks` argument. A map of main-repo
38-
relative paths to File.
3936
"""
4037

4138
# maps venv-relative path to the runfiles path it should point to
@@ -49,31 +46,25 @@ def create_venv_app_files(ctx, deps, venv_dir_map):
4946

5047
link_map = build_link_map(ctx, entries)
5148
venv_files = []
52-
runfiles_symlinks = {}
5349

5450
for kind, kind_map in link_map.items():
5551
base = venv_dir_map[kind]
5652
for venv_path, link_to in kind_map.items():
5753
bin_venv_path = paths.join(base, venv_path)
58-
if is_file(link_to):
59-
symlink_from = "{}/{}".format(ctx.label.package, bin_venv_path)
60-
runfiles_symlinks[symlink_from] = link_to
61-
62-
else:
63-
venv_link = ctx.actions.declare_symlink(bin_venv_path)
64-
venv_link_rf_path = runfiles_root_path(ctx, venv_link.short_path)
65-
rel_path = relative_path(
66-
# dirname is necessary because a relative symlink is relative to
67-
# the directory the symlink resides within.
68-
from_ = paths.dirname(venv_link_rf_path),
69-
to = link_to,
70-
)
71-
ctx.actions.symlink(output = venv_link, target_path = rel_path)
72-
venv_files.append(venv_link)
54+
link_to_path = link_to.short_path if is_file(link_to) else link_to
55+
venv_link = ctx.actions.declare_symlink(bin_venv_path)
56+
venv_link_rf_path = runfiles_root_path(ctx, venv_link.short_path)
57+
rel_path = relative_path(
58+
# dirname is necessary because a relative symlink is relative to
59+
# the directory the symlink resides within.
60+
from_ = paths.dirname(venv_link_rf_path),
61+
to = link_to_path,
62+
)
63+
ctx.actions.symlink(output = venv_link, target_path = rel_path)
64+
venv_files.append(venv_link)
7365

7466
return struct(
7567
venv_files = venv_files,
76-
runfiles_symlinks = runfiles_symlinks,
7768
)
7869

7970
# Visible for testing

0 commit comments

Comments
 (0)