@@ -372,7 +372,7 @@ def _whl_repo(*, src, whl_library_args, is_multiple_versions, download_only, net
372372 ),
373373 )
374374
375- def _configure (config , * , platform , os_name , arch_name , override = False , ** values ):
375+ def _configure (config , * , platform , os_name , arch_name , constraint_values , override = False , ** values ):
376376 """Set the value in the config if the value is provided"""
377377 config .setdefault ("platforms" , {})
378378 if platform :
@@ -383,6 +383,7 @@ def _configure(config, *, platform, os_name, arch_name, override = False, **valu
383383 name = platform .replace ("-" , "_" ).lower (),
384384 os_name = os_name ,
385385 arch_name = arch_name ,
386+ constraint_values = constraint_values ,
386387 env = {
387388 k [4 :]: v
388389 for k , v in values .items ()
@@ -414,6 +415,10 @@ def _create_config(defaults):
414415 env_platform_version = "0" ,
415416 os_name = "linux" ,
416417 platform = "linux_{}" .format (cpu ),
418+ constraint_values = [
419+ "@platforms//os:linux" ,
420+ "@platforms//cpu:{}" .format (cpu ),
421+ ],
417422 )
418423 for cpu in [
419424 "aarch64" ,
@@ -427,6 +432,10 @@ def _create_config(defaults):
427432 env_platform_version = "14.0" ,
428433 os_name = "osx" ,
429434 platform = "osx_{}" .format (cpu ),
435+ constraint_values = [
436+ "@platforms//os:osx" ,
437+ "@platforms//cpu:{}" .format (cpu ),
438+ ],
430439 )
431440
432441 _configure (
@@ -435,6 +444,10 @@ def _create_config(defaults):
435444 env_platform_version = "0" ,
436445 os_name = "windows" ,
437446 platform = "windows_x86_64" ,
447+ constraint_values = [
448+ "@platforms//os:windows" ,
449+ "@platforms//cpu:x86_64" ,
450+ ],
438451 )
439452 return struct (** defaults )
440453
@@ -500,6 +513,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
500513 _configure (
501514 defaults ,
502515 arch_name = tag .arch_name ,
516+ constraint_values = tag .constraint_values ,
503517 # The env_ values is only used if the `PIPSTAR` is enabled
504518 env_implementation_name = tag .env_implementation_name ,
505519 env_os_name = tag .env_os_name ,
@@ -684,6 +698,13 @@ You cannot use both the additive_build_content and additive_build_content_file a
684698 }
685699 for hub_name , extra_whl_aliases in extra_aliases .items ()
686700 },
701+ platform_constraint_values = {
702+ hub_name : {
703+ platform_name : sorted ([str (Label (cv )) for cv in p .constraint_values ])
704+ for platform_name , p in config .platforms .items ()
705+ }
706+ for hub_name in hub_whl_map
707+ },
687708 whl_libraries = {
688709 k : dict (sorted (args .items ()))
689710 for k , args in sorted (whl_libraries .items ())
@@ -774,6 +795,7 @@ def _pip_impl(module_ctx):
774795 for key , values in whl_map .items ()
775796 },
776797 packages = mods .exposed_packages .get (hub_name , []),
798+ platform_constraint_values = mods .platform_constraint_values .get (hub_name , {}),
777799 groups = mods .hub_group_map .get (hub_name ),
778800 )
779801
@@ -793,6 +815,12 @@ The CPU architecture name to be used.
793815:::{note}
794816Either this or {attr}`env_platform_machine` should be specified.
795817:::
818+ """ ,
819+ ),
820+ "constraint_values" : attr .label_list (
821+ mandatory = True ,
822+ doc = """\
823+ The constraint_values to use in select statements.
796824""" ,
797825 ),
798826 "os_name" : attr .string (
0 commit comments