Skip to content

Commit 30c1d01

Browse files
committed
comment: pass pkg with version
1 parent fa1249a commit 30c1d01

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

python/private/py_executable.bzl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,19 +686,25 @@ def _build_link_map(entries):
686686
# Here we store venv paths by package
687687
# dict[str package, dict[str kind, list[str venv_path]]]
688688
pkg_map = {}
689+
689690
for entry in entries:
690691
kind = entry.kind
691692
kind_map = link_map.setdefault(kind, {})
692693

694+
# TODO @aignas 2025-05-31: explain where we use the version
695+
package = None
696+
if entry.package:
697+
package, _, _version = entry.package.partition("-")
698+
693699
# If we detect that we are adding a dist-info for an already existing package
694700
# we need to pop all of the previous symlinks from the link_map
695-
if entry.venv_path.endswith(".dist-info") and entry.package in pkg_map:
701+
if entry.venv_path.endswith(".dist-info") and package in pkg_map:
696702
# dist-info will come always first
697-
for kind, dir_paths in pkg_map.pop(entry.package).items():
703+
for kind, dir_paths in pkg_map.pop(package).items():
698704
for dir_path in dir_paths:
699705
link_map[kind].pop(dir_path)
700706

701-
pkg_venv_paths = pkg_map.setdefault(entry.package, {}).setdefault(entry.kind, [])
707+
pkg_venv_paths = pkg_map.setdefault(package, {}).setdefault(entry.kind, [])
702708
pkg_venv_paths.append(entry.venv_path)
703709

704710
# We overwrite duplicates by design. The dependency closer to the

python/private/py_library.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ load(
5353
"EXEC_TOOLS_TOOLCHAIN_TYPE",
5454
TOOLCHAIN_TYPE = "TARGET_TOOLCHAIN_TYPE",
5555
)
56+
load(":version.bzl", "version")
5657

5758
_py_builtins = py_internal
5859

@@ -279,8 +280,11 @@ def _get_venv_symlinks(ctx, dist_info_metadata):
279280
# directories by checking if the package key is there.
280281
dist_info_dir = paths.basename(dist_info_metadata.dirname)
281282
package, _, _suffix = dist_info_dir.rpartition(".dist-info")
282-
package, _, _version = package.rpartition("-")
283-
package = normalize_name(package)
283+
package, _, version_str = package.rpartition("-")
284+
package = "{}-{}".format(
285+
normalize_name(package),
286+
version.normalize(version_str),
287+
)
284288

285289
repo_runfiles_dirname = runfiles_root_path(ctx, dist_info_metadata.short_path).partition("/")[0]
286290
venv_symlinks.append(VenvSymlinkEntry(

0 commit comments

Comments
 (0)