Skip to content

Commit

Permalink
Use an alias, not an empty py_library
Browse files Browse the repository at this point in the history
And clarify the generated target names somewhat
  • Loading branch information
arrdem committed May 18, 2023
1 parent 8ed5a6e commit 1b46a33
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/pip_parse_vendored/requirements.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 3 additions & 4 deletions python/pip_install/pip_repository_lib.bzl.tmpl
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion python/pip_install/pip_repository_requirements.bzl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 1b46a33

Please sign in to comment.