@@ -270,7 +270,7 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
270270 # the path to symlink to.
271271
272272 repo_runfiles_dirname = None
273- dirs_with_init = {} # dirname -> runfile path
273+ dir_symlinks = {} # dirname -> runfile path
274274 venv_symlinks = []
275275 package = None
276276 if dist_info_metadata :
@@ -305,15 +305,16 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
305305 # we have already handled the stuff
306306 continue
307307
308- if src .extension not in PYTHON_FILE_EXTENSIONS :
309- fail ("TODO, symlinking non-Python files is not yet supported: {}" .format (src ))
310- elif dir_name :
308+ if dir_name :
311309 # This can be either a directory with libs (e.g. numpy.libs)
312310 # or a directory with `__init__.py` file that potentially also needs to be
313311 # symlinked.
314- dirs_with_init [dir_name ] = None
312+ #
313+ # This could be also regular files, that just need to be symlinked, so we will
314+ # add the directory here.
315315 repo_runfiles_dirname = runfiles_root_path (ctx , src .short_path ).partition ("/" )[0 ]
316- else :
316+ dir_symlinks [dir_name ] = repo_runfiles_dirname
317+ elif src .extension in PYTHON_FILE_EXTENSIONS :
317318 repo_runfiles_dirname = runfiles_root_path (ctx , src .short_path ).partition ("/" )[0 ]
318319
319320 # This would be files that do not have directories and we just need to add
@@ -327,7 +328,7 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
327328
328329 # Sort so that we encounter `foo` before `foo/bar`. This ensures we
329330 # see the top-most explicit package first.
330- dirnames = sorted (dirs_with_init .keys ())
331+ dirnames = sorted (dir_symlinks .keys ())
331332 first_level_explicit_packages = []
332333 for d in dirnames :
333334 is_sub_package = False
@@ -340,9 +341,10 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
340341 first_level_explicit_packages .append (d )
341342
342343 for dirname in first_level_explicit_packages :
344+ prefix = dir_symlinks [dirname ]
343345 venv_symlinks .append (VenvSymlinkEntry (
344346 kind = VenvSymlinkKind .LIB ,
345- link_to_path = paths .join (repo_runfiles_dirname , site_packages_root , dirname ),
347+ link_to_path = paths .join (prefix , site_packages_root , dirname ),
346348 package = package ,
347349 venv_path = dirname ,
348350 ))
0 commit comments