4141 "runfiles_root_path" ,
4242)
4343load (":flags.bzl" , "AddSrcsToRunfilesFlag" , "PrecompileFlag" , "VenvsSitePackages" )
44+ load (":normalize_name.bzl" , "normalize_name" )
4445load (":precompile.bzl" , "maybe_precompile" )
4546load (":py_cc_link_params_info.bzl" , "PyCcLinkParamsInfo" )
4647load (":py_info.bzl" , "PyInfo" , "VenvSymlinkEntry" , "VenvSymlinkKind" )
@@ -270,20 +271,21 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
270271 repo_runfiles_dirname = None
271272 dirs_with_init = {} # dirname -> runfile path
272273 venv_symlinks = []
274+ package = ""
273275 if dist_info_metadata :
274276 # in order to be able to have replacements in the venv, we have to add a
275277 # third value into the venv_symlinks, which would be the normalized
276278 # package name. This allows us to ensure that we can replace the `dist-info`
277279 # directories by checking if the package key is there.
278280 dist_info_dir = paths .basename (dist_info_metadata .dirname )
279- #TODO remove
280- #package, _, _suffix = dist_info_dir.rpartition(".dist-info")
281- #package, _, _version = package.rpartition("-")
282- #symlink_key = "{}.dist-info".format(normalize_name(package))
281+ package , _ , _suffix = dist_info_dir .rpartition (".dist-info" )
282+ package , _ , _version = package .rpartition ("-" )
283+ package = normalize_name (package )
283284
284285 repo_runfiles_dirname = runfiles_root_path (ctx , dist_info_metadata .short_path ).partition ("/" )[0 ]
285286 venv_symlinks .append (VenvSymlinkEntry (
286- kind = VenvSymlinkKind .DISTINFO ,
287+ key = "{}.dist-info" .format (package ),
288+ kind = VenvSymlinkKind .LIB ,
287289 link_to_path = paths .join (repo_runfiles_dirname , site_packages_root , dist_info_dir ),
288290 venv_path = dist_info_dir ,
289291 ))
@@ -306,6 +308,7 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
306308 # This would be files that do not have directories and we just need to add
307309 # direct symlinks to them as is:
308310 venv_symlinks .append (VenvSymlinkEntry (
311+ key = None ,
309312 kind = VenvSymlinkKind .LIB ,
310313 link_to_path = paths .join (repo_runfiles_dirname , site_packages_root , filename ),
311314 venv_path = filename ,
@@ -327,6 +330,7 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
327330
328331 for dirname in first_level_explicit_packages :
329332 venv_symlinks .append (VenvSymlinkEntry (
333+ key = None ,
330334 kind = VenvSymlinkKind .LIB ,
331335 link_to_path = paths .join (repo_runfiles_dirname , site_packages_root , dirname ),
332336 venv_path = dirname ,
0 commit comments