1616
1717load ("@bazel_features//:features.bzl" , "bazel_features" )
1818load ("@pythons_hub//:interpreters.bzl" , "INTERPRETER_LABELS" )
19+ load ("@pythons_hub//:versions.bzl" , "MINOR_MAPPING" )
1920load ("//python/private:auth.bzl" , "AUTH_ATTRS" )
21+ load ("//python/private:full_version.bzl" , "full_version" )
2022load ("//python/private:normalize_name.bzl" , "normalize_name" )
2123load ("//python/private:repo_utils.bzl" , "repo_utils" )
2224load ("//python/private:semver.bzl" , "semver" )
@@ -173,6 +175,7 @@ def _create_whl_repos(
173175        logger  =  logger ,
174176    )
175177
178+     platforms  =  {}
176179    for  whl_name , requirements  in  requirements_by_platform .items ():
177180        group_name  =  whl_group_mapping .get (whl_name )
178181        group_deps  =  requirement_cycles .get (group_name , [])
@@ -233,6 +236,10 @@ def _create_whl_repos(
233236                    ))
234237
235238                whl_libraries [repo_name ] =  args 
239+ 
240+                 # TODO @aignas 2025-03-23: make this more efficient 
241+                 for  p  in  args .pop ("experimental_target_platforms" , []):
242+                     platforms [p ] =  None 
236243                whl_map .setdefault (whl_name , {})[config_setting ] =  repo_name 
237244
238245    return  struct (
@@ -244,6 +251,7 @@ def _create_whl_repos(
244251        },
245252        extra_aliases  =  extra_aliases ,
246253        whl_libraries  =  whl_libraries ,
254+         platforms  =  platforms ,
247255    )
248256
249257def  _whl_repos (* , requirement , whl_library_args , download_only , netrc , auth_patterns , multiple_requirements_for_whl  =  False , python_version ):
@@ -408,6 +416,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
408416    exposed_packages  =  {}
409417    extra_aliases  =  {}
410418    whl_libraries  =  {}
419+     platforms  =  {}
411420
412421    is_reproducible  =  True 
413422
@@ -485,6 +494,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
485494                extra_aliases [hub_name ].setdefault (whl_name , {}).update (aliases )
486495            exposed_packages .setdefault (hub_name , {}).update (out .exposed_packages )
487496            whl_libraries .update (out .whl_libraries )
497+             platforms .setdefault (hub_name , {}).update (out .platforms )
488498
489499            # TODO @aignas 2024-04-05: how do we support different requirement 
490500            # cycles for different abis/oses? For now we will need the users to 
@@ -521,6 +531,17 @@ You cannot use both the additive_build_content and additive_build_content_file a
521531            }
522532            for  hub_name , extra_whl_aliases  in  extra_aliases .items ()
523533        },
534+         platforms  =  {
535+             hub_name : sorted (p )
536+             for  hub_name , p  in  platforms .items ()
537+         },
538+         python_versions  =  {
539+             hub_name : sorted ({
540+                 full_version (version  =  v , minor_mapping  =  MINOR_MAPPING ): None 
541+                 for  v  in  m .python_versions 
542+             })
543+             for  hub_name , m  in  pip_hub_map .items ()
544+         },
524545        whl_libraries  =  {
525546            k : dict (sorted (args .items ()))
526547            for  k , args  in  sorted (whl_libraries .items ())
@@ -612,6 +633,8 @@ def _pip_impl(module_ctx):
612633                for  key , values  in  whl_map .items ()
613634            },
614635            packages  =  mods .exposed_packages .get (hub_name , []),
636+             python_versions  =  mods .python_versions [hub_name ],
637+             platforms  =  mods .platforms .get (hub_name , ["host" ]),
615638            groups  =  mods .hub_group_map .get (hub_name ),
616639        )
617640
0 commit comments