Skip to content

Commit f48fdc0

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

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
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: 14 additions & 19 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,29 @@ 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
6154

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)
55+
# Just for demonstration purposes,
56+
# there is definitely a better thing to do upstream that removeprefix("../")
57+
link_to_path = link_to.short_path.removeprefix("../") if is_file(link_to) else link_to
58+
59+
venv_link = ctx.actions.declare_symlink(bin_venv_path)
60+
venv_link_rf_path = runfiles_root_path(ctx, venv_link.short_path)
61+
rel_path = relative_path(
62+
# dirname is necessary because a relative symlink is relative to
63+
# the directory the symlink resides within.
64+
from_ = paths.dirname(venv_link_rf_path),
65+
to = link_to_path,
66+
)
67+
ctx.actions.symlink(output = venv_link, target_path = rel_path)
68+
venv_files.append(venv_link)
7369

7470
return struct(
7571
venv_files = venv_files,
76-
runfiles_symlinks = runfiles_symlinks,
7772
)
7873

7974
# Visible for testing

0 commit comments

Comments
 (0)