@@ -392,7 +392,7 @@ def _whl_repo(*, src, whl_library_args, is_multiple_versions, download_only, net
392392def _configure (config , * , platform , os_name , arch_name , config_settings , env = {}, want_abis , platform_tags , override = False ):
393393 """Set the value in the config if the value is provided"""
394394 config .setdefault ("platforms" , {})
395- if platform :
395+ if platform and ( os_name or arch_name or config_settings or platform_tags or env ) :
396396 if not override and config .get ("platforms" , {}).get (platform ):
397397 return
398398
@@ -429,9 +429,12 @@ def _configure(config, *, platform, os_name, arch_name, config_settings, env = {
429429 else :
430430 config ["platforms" ].pop (platform )
431431
432- def _create_config (defaults ):
433- if defaults ["platforms" ]:
434- return struct (** defaults )
432+ def _set_defaults (defaults ):
433+ """Set defaults that rules_python is operating under.
434+
435+ Because this code is also tested in unit tests, leaving it in MODULE.bazel would be
436+ a little problematic.
437+ """
435438
436439 # NOTE: We have this so that it is easier to maintain unit tests assuming certain
437440 # defaults
@@ -488,22 +491,24 @@ def _create_config(defaults):
488491 },
489492 )
490493
491- _configure (
492- defaults ,
493- arch_name = "x86_64" ,
494- os_name = "windows" ,
495- platform = "windows_x86_64" ,
496- config_settings = [
497- "@platforms//os:windows" ,
498- "@platforms//cpu:x86_64" ,
499- ],
500- want_abis = [],
501- platform_tags = ["win_amd64" ],
502- env = {
503- "platform_version" : "0" ,
504- },
505- )
506- return struct (** defaults )
494+ for cpu , platform_tags in {
495+ "x86_64" : ["win_amd64" ],
496+ }.items ():
497+ _configure (
498+ defaults ,
499+ arch_name = cpu ,
500+ os_name = "windows" ,
501+ platform = "windows_{}" .format (cpu ),
502+ config_settings = [
503+ "@platforms//os:windows" ,
504+ "@platforms//cpu:{}" .format (cpu ),
505+ ],
506+ want_abis = [],
507+ platform_tags = platform_tags ,
508+ env = {
509+ "platform_version" : "0" ,
510+ },
511+ )
507512
508513def parse_modules (
509514 module_ctx ,
@@ -559,6 +564,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
559564 "enable_pipstar" : enable_pipstar ,
560565 "platforms" : {},
561566 }
567+ _set_defaults (defaults )
562568 for mod in module_ctx .modules :
563569 if not (mod .is_root or mod .name == "rules_python" ):
564570 continue
@@ -582,7 +588,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
582588 # * for whl selection - We could also model the `cp313t` freethreaded as separate platforms.
583589 )
584590
585- config = _create_config ( defaults )
591+ config = struct ( ** defaults )
586592
587593 # TODO @aignas 2025-06-03: Merge override API with the builder?
588594 _overriden_whl_set = {}
0 commit comments