@@ -30,7 +30,12 @@ def create_venv_app_files(ctx, deps, venv_dir_map):
3030 paths within the current ctx's venv (e.g. `_foo.venv/bin`).
3131
3232 Returns:
33- {type}`list[File]` of the files that were created.
33+ {type}`struct` with the following attributes:
34+ * {type}`list[File]` `venv_files` additional files created for
35+ 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.
3439 """
3540
3641 # maps venv-relative path to the runfiles path it should point to
@@ -44,16 +49,16 @@ def create_venv_app_files(ctx, deps, venv_dir_map):
4449
4550 link_map = build_link_map (ctx , entries )
4651 venv_files = []
52+ runfiles_symlinks = {}
53+
4754 for kind , kind_map in link_map .items ():
4855 base = venv_dir_map [kind ]
4956 for venv_path , link_to in kind_map .items ():
5057 bin_venv_path = paths .join (base , venv_path )
5158 if is_file (link_to ):
52- if link_to .is_directory :
53- venv_link = ctx .actions .declare_directory (bin_venv_path )
54- else :
55- venv_link = ctx .actions .declare_file (bin_venv_path )
56- ctx .actions .symlink (output = venv_link , target_file = link_to )
59+ symlink_from = "{}/{}" .format (ctx .label .package , bin_venv_path )
60+ runfiles_symlinks [symlink_from ] = link_to
61+
5762 else :
5863 venv_link = ctx .actions .declare_symlink (bin_venv_path )
5964 venv_link_rf_path = runfiles_root_path (ctx , venv_link .short_path )
@@ -64,9 +69,12 @@ def create_venv_app_files(ctx, deps, venv_dir_map):
6469 to = link_to ,
6570 )
6671 ctx .actions .symlink (output = venv_link , target_path = rel_path )
67- venv_files .append (venv_link )
72+ venv_files .append (venv_link )
6873
69- return venv_files
74+ return struct (
75+ venv_files = venv_files ,
76+ runfiles_symlinks = runfiles_symlinks ,
77+ )
7078
7179# Visible for testing
7280def build_link_map (ctx , entries ):
0 commit comments