@@ -23,13 +23,13 @@ load("//python/private:semver.bzl", "semver")
2323load ("//python/private:version_label.bzl" , "version_label" )
2424load (":attrs.bzl" , "use_isolated" )
2525load (":evaluate_markers.bzl" , "evaluate_markers" , EVALUATE_MARKERS_SRCS = "SRCS" )
26- load (":hub_repository.bzl" , "hub_repository" )
26+ load (":hub_repository.bzl" , "hub_repository" , "whl_config_settings_to_json" )
2727load (":parse_requirements.bzl" , "parse_requirements" )
2828load (":parse_whl_name.bzl" , "parse_whl_name" )
2929load (":pip_repository_attrs.bzl" , "ATTRS" )
30- load (":render_pkg_aliases.bzl" , "whl_alias" )
3130load (":requirements_files_by_platform.bzl" , "requirements_files_by_platform" )
3231load (":simpleapi_download.bzl" , "simpleapi_download" )
32+ load (":whl_config_setting.bzl" , "whl_config_setting" )
3333load (":whl_library.bzl" , "whl_library" )
3434load (":whl_repo_name.bzl" , "pypi_repo_name" , "whl_repo_name" )
3535
@@ -87,7 +87,7 @@ def _create_whl_repos(
8787 Returns a {type}`struct` with the following attributes:
8888 whl_map: {type}`dict[str, list[struct]]` the output is keyed by the
8989 normalized package name and the values are the instances of the
90- {bzl:obj}`whl_alias ` return values.
90+ {bzl:obj}`whl_config_setting ` return values.
9191 exposed_packages: {type}`dict[str, Any]` this is just a way to
9292 represent a set of string values.
9393 whl_libraries: {type}`dict[str, dict[str, Any]]` the keys are the
@@ -304,14 +304,11 @@ def _create_whl_repos(
304304
305305 whl_libraries [repo_name ] = args
306306
307- whl_map .setdefault (whl_name , []).append (
308- whl_alias (
309- repo = repo_name ,
310- version = major_minor ,
311- filename = distribution .filename ,
312- target_platforms = target_platforms ,
313- ),
314- )
307+ whl_map .setdefault (whl_name , {})[whl_config_setting (
308+ version = major_minor ,
309+ filename = distribution .filename ,
310+ target_platforms = target_platforms ,
311+ )] = repo_name
315312
316313 if found_something :
317314 if is_exposed :
@@ -339,13 +336,10 @@ def _create_whl_repos(
339336 * target_platforms
340337 )
341338 whl_libraries [repo_name ] = args
342- whl_map .setdefault (whl_name , []).append (
343- whl_alias (
344- repo = repo_name ,
345- version = major_minor ,
346- target_platforms = target_platforms or None ,
347- ),
348- )
339+ whl_map .setdefault (whl_name , {})[whl_config_setting (
340+ version = major_minor ,
341+ target_platforms = target_platforms or None ,
342+ )] = repo_name
349343
350344 if is_exposed :
351345 exposed_packages [whl_name ] = None
@@ -488,7 +482,8 @@ You cannot use both the additive_build_content and additive_build_content_file a
488482 )
489483 hub_whl_map .setdefault (hub_name , {})
490484 for key , settings in out .whl_map .items ():
491- hub_whl_map [hub_name ].setdefault (key , []).extend (settings )
485+ for setting , repo in settings .items ():
486+ hub_whl_map [hub_name ].setdefault (key , {}).setdefault (repo , []).append (setting )
492487 extra_aliases .setdefault (hub_name , {})
493488 for whl_name , aliases in out .extra_aliases .items ():
494489 extra_aliases [hub_name ].setdefault (whl_name , {}).update (aliases )
@@ -508,7 +503,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
508503 whl_mods = dict (sorted (whl_mods .items ())),
509504 hub_whl_map = {
510505 hub_name : {
511- whl_name : sorted (settings , key = lambda x : ( x . version , x . filename ) )
506+ whl_name : dict (settings )
512507 for whl_name , settings in sorted (whl_map .items ())
513508 }
514509 for hub_name , whl_map in sorted (hub_whl_map .items ())
@@ -538,20 +533,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
538533 is_reproducible = is_reproducible ,
539534 )
540535
541- def _alias_dict (a ):
542- ret = {
543- "repo" : a .repo ,
544- }
545- if a .config_setting :
546- ret ["config_setting" ] = a .config_setting
547- if a .filename :
548- ret ["filename" ] = a .filename
549- if a .target_platforms :
550- ret ["target_platforms" ] = a .target_platforms
551- if a .version :
552- ret ["version" ] = a .version
553- return ret
554-
555536def _pip_impl (module_ctx ):
556537 """Implementation of a class tag that creates the pip hub and corresponding pip spoke whl repositories.
557538
@@ -632,8 +613,8 @@ def _pip_impl(module_ctx):
632613 repo_name = hub_name ,
633614 extra_hub_aliases = mods .extra_aliases .get (hub_name , {}),
634615 whl_map = {
635- key : json . encode ([ _alias_dict ( a ) for a in aliases ] )
636- for key , aliases in whl_map .items ()
616+ key : whl_config_settings_to_json ( values )
617+ for key , values in whl_map .items ()
637618 },
638619 packages = mods .exposed_packages .get (hub_name , []),
639620 groups = mods .hub_group_map .get (hub_name ),
0 commit comments