From 1b46a331ce46a3e8bf1860a36442b7f8818d9ac6 Mon Sep 17 00:00:00 2001 From: "Reid D. McKenzie" Date: Wed, 17 May 2023 19:59:28 -0600 Subject: [PATCH] Use an alias, not an empty py_library And clarify the generated target names somewhat --- examples/pip_parse_vendored/requirements.bzl | 2 +- python/pip_install/pip_repository_lib.bzl.tmpl | 7 +++---- python/pip_install/pip_repository_requirements.bzl.tmpl | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/pip_parse_vendored/requirements.bzl b/examples/pip_parse_vendored/requirements.bzl index 4a36b96f99..160bef80de 100644 --- a/examples/pip_parse_vendored/requirements.bzl +++ b/examples/pip_parse_vendored/requirements.bzl @@ -94,7 +94,7 @@ def _clean_name(name): def requirement(name, use_clusters = True): cname = _clean_name(name) if cname in _cluster_mappings and use_clusters: - return "@pip//:{}_{}".format(_cluster_mappings[cname], cname) + return "@pip//:_cluster_{}_dep_{}".format(_cluster_mappings[cname], cname) else: return "@pip_" + cname + "//:pkg" diff --git a/python/pip_install/pip_repository_lib.bzl.tmpl b/python/pip_install/pip_repository_lib.bzl.tmpl index b49fda84ad..46145ec282 100644 --- a/python/pip_install/pip_repository_lib.bzl.tmpl +++ b/python/pip_install/pip_repository_lib.bzl.tmpl @@ -1,7 +1,6 @@ load("@rules_python//python:defs.bzl", "py_library") load("//:requirements.bzl", "requirement", "whl_requirement", "requirement_clusters") - def install_clusters(): for cluster_name, components in requirement_clusters.items(): py_library( @@ -11,9 +10,9 @@ def install_clusters(): for r in components: requirement_name = r[0] - py_library( - name = "{}_{}".format(cluster_name, requirement_name), - deps = [cluster_name], + native.alias( + name = "_cluster_{}_dep_{}".format(cluster_name, requirement_name), + actual = cluster_name, ) native.filegroup( diff --git a/python/pip_install/pip_repository_requirements.bzl.tmpl b/python/pip_install/pip_repository_requirements.bzl.tmpl index 28fa75c618..42c86d0447 100644 --- a/python/pip_install/pip_repository_requirements.bzl.tmpl +++ b/python/pip_install/pip_repository_requirements.bzl.tmpl @@ -26,7 +26,7 @@ def _clean_name(name): def requirement(name, use_clusters = True): cname = _clean_name(name) if cname in _cluster_mappings and use_clusters: - return "@%%NAME%%//:{}_{}".format(_cluster_mappings[cname], cname) + return "@%%NAME%%//:_cluster_{}_dep_{}".format(_cluster_mappings[cname], cname) else: return "@%%NAME%%_" + cname + "//:pkg"