@@ -68,7 +68,7 @@ def whl_library_targets_from_requires(
6868 name = name ,
6969 python_version = python_version ,
7070 requires_dist = requires_dist ,
71- exclude = group_deps ,
71+ excludes = group_deps ,
7272 extras = extras ,
7373 target_platforms = target_platforms ,
7474 )
@@ -88,12 +88,9 @@ def _parse_requires_dist(
8888 name ,
8989 python_version ,
9090 requires_dist ,
91- exclude ,
91+ excludes ,
9292 extras ,
9393 target_platforms ):
94- # TODO @aignas 2025-04-15: split this function into 2 where we are passing `package_deps` from the first function to the second.
95- #
96- # this will make unit testing of the functions easier
9794 parsed_whl = parse_whl_name (name )
9895
9996 # NOTE @aignas 2023-12-04: if the wheel is a platform specific wheel, we
@@ -111,9 +108,9 @@ def _parse_requires_dist(
111108 name = normalize_name (parsed_whl .distribution ),
112109 requires_dist = requires_dist ,
113110 platforms = target_platforms ,
114- exclude = exclude ,
111+ excludes = excludes ,
115112 extras = extras ,
116- default_python_version = python_version ,
113+ host_python_version = python_version ,
117114 )
118115
119116def whl_library_targets (
@@ -129,6 +126,7 @@ def whl_library_targets(
129126 },
130127 dependencies = [],
131128 dependencies_by_platform = {},
129+ group_deps = [],
132130 group_name = "" ,
133131 data = [],
134132 copy_files = {},
@@ -157,6 +155,10 @@ def whl_library_targets(
157155 contains this library. If set, this library will behave as a shim
158156 to group implementation rules which will provide simultaneously
159157 installed dependencies which would otherwise form a cycle.
158+ group_deps: {type}`list[str]` names of fellow members of the group (if
159+ any). These will be excluded from generated deps lists so as to avoid
160+ direct cycles. These dependencies will be provided at runtime by the
161+ group rules which wrap this library and its fellows together.
160162 copy_executables: {type}`dict[str, str]` The mapping between src and
161163 dest locations for the targets.
162164 copy_files: {type}`dict[str, str]` The mapping between src and
@@ -176,6 +178,7 @@ def whl_library_targets(
176178 platform : sorted ([normalize_name (d ) for d in deps ])
177179 for platform , deps in dependencies_by_platform .items ()
178180 }
181+ tags = sorted (tags )
179182 data = [] + data
180183
181184 for filegroup_name , glob in filegroups .items ():
@@ -204,11 +207,7 @@ def whl_library_targets(
204207 data .append (dest )
205208
206209 _config_settings (
207- sorted ({
208- p : None
209- for platforms in dependencies_by_platform .values ()
210- for p in platforms
211- }),
210+ dependencies_by_platform .keys (),
212211 native = native ,
213212 visibility = ["//visibility:private" ],
214213 )
@@ -227,6 +226,25 @@ def whl_library_targets(
227226 visibility = ["//visibility:public" ],
228227 )
229228
229+ # Ensure this list is normalized
230+ # Note: mapping used as set
231+ group_deps = {
232+ normalize_name (d ): True
233+ for d in group_deps
234+ }
235+
236+ dependencies = [
237+ d
238+ for d in dependencies
239+ if d not in group_deps
240+ ]
241+ dependencies_by_platform = {
242+ p : deps
243+ for p , deps in dependencies_by_platform .items ()
244+ for deps in [[d for d in deps if d not in group_deps ]]
245+ if deps
246+ }
247+
230248 # If this library is a member of a group, its public label aliases need to
231249 # point to the group implementation rule not the implementation rules. We
232250 # also need to mark the implementation rules as visible to the group
@@ -393,12 +411,22 @@ def _plat_label(plat):
393411def _deps (deps , deps_by_platform , tmpl , select = select ):
394412 deps = [tmpl .format (d ) for d in sorted (deps )]
395413
396- for dep , platforms in deps_by_platform .items ():
397- deps += select ({
398- "//conditions:default" : [],
399- } | {
400- _plat_label (p ): [tmpl .format (dep )]
401- for p in platforms
402- })
414+ if not deps_by_platform :
415+ return deps
403416
404- return deps
417+ deps_by_platform = {
418+ _plat_label (p ): [
419+ tmpl .format (d )
420+ for d in sorted (deps )
421+ ]
422+ for p , deps in sorted (deps_by_platform .items ())
423+ }
424+
425+ # Add the default, which means that we will be just using the dependencies in
426+ # `deps` for platforms that are not handled in a special way by the packages
427+ deps_by_platform .setdefault ("//conditions:default" , [])
428+
429+ if not deps :
430+ return select (deps_by_platform )
431+ else :
432+ return deps + select (deps_by_platform )
0 commit comments