@@ -405,7 +405,7 @@ def _python_impl(module_ctx):
405405
406406 # Extra target_settings to add to every registered toolchain, e.g. for
407407 # gating the default toolchains behind a custom config_setting.
408- global_toolchain_target_settings = py .config .toolchain_target_settings
408+ global_add_target_settings = py .config .add_target_settings
409409
410410 # Split the toolchain info into separate objects so they can be passed onto
411411 # the repository rule.
@@ -418,7 +418,7 @@ def _python_impl(module_ctx):
418418
419419 # The target_settings attribute may not be present for users
420420 # patching python/versions.bzl.
421- toolchain_ts_map [key ] = getattr (entry .platform , "target_settings" , []) + global_toolchain_target_settings
421+ toolchain_ts_map [key ] = getattr (entry .platform , "target_settings" , []) + global_add_target_settings
422422 toolchain_platform_keys [key ] = entry .platform_name
423423 toolchain_python_versions [key ] = entry .full_python_version
424424
@@ -706,8 +706,8 @@ def _process_global_overrides(*, tag, default, _fail = fail):
706706
707707 default ["minor_mapping" ] = tag .minor_mapping
708708
709- if tag .toolchain_target_settings :
710- default ["toolchain_target_settings " ] = list (tag .toolchain_target_settings )
709+ if tag .add_target_settings :
710+ default ["add_target_settings " ] = list (tag .add_target_settings )
711711
712712 forwarded_attrs = sorted (AUTH_ATTRS ) + [
713713 "base_url" ,
@@ -816,7 +816,7 @@ def _get_toolchain_config(*, modules, _fail = fail):
816816 )
817817
818818 register_all_versions = default .pop ("register_all_versions" , False )
819- toolchain_target_settings = default .pop ("toolchain_target_settings " , [])
819+ add_target_settings = default .pop ("add_target_settings " , [])
820820 kwargs = default .pop ("kwargs" , {})
821821
822822 versions = {}
@@ -842,7 +842,7 @@ def _get_toolchain_config(*, modules, _fail = fail):
842842 minor_mapping = minor_mapping ,
843843 default = default ,
844844 register_all_versions = register_all_versions ,
845- toolchain_target_settings = toolchain_target_settings ,
845+ add_target_settings = add_target_settings ,
846846 )
847847
848848def _compute_default_python_version (mctx ):
@@ -1108,6 +1108,30 @@ _override = tag_class(
11081108:::
11091109""" ,
11101110 attrs = {
1111+ "add_target_settings" : attr .string_list (
1112+ mandatory = False ,
1113+ doc = """\
1114+ A list of `config_setting` labels to add to the `target_settings` of every
1115+ toolchain registered by this module extension. This is useful for creating
1116+ separate "families" of toolchains gated behind custom build settings.
1117+
1118+ For example, to ensure the default prebuilt toolchains are only resolved when
1119+ a `prebuilt` config setting is active:
1120+
1121+ ```starlark
1122+ python.override(
1123+ add_target_settings = ["@@//:python_toolchain_family_prebuilt"],
1124+ )
1125+ ```
1126+
1127+ These settings are appended to the `target_settings` of all toolchains
1128+ registered by the extension, including any that already have settings
1129+ from `python.single_version_platform_override`.
1130+
1131+ :::{versionadded} VERSION_NEXT_FEATURE
1132+ :::
1133+ """ ,
1134+ ),
11111135 "available_python_versions" : attr .string_list (
11121136 mandatory = False ,
11131137 doc = """\
@@ -1153,30 +1177,6 @@ The values in this mapping override the default values and do not replace them.
11531177 default = {},
11541178 ),
11551179 "register_all_versions" : attr .bool (default = False , doc = "Add all versions" ),
1156- "toolchain_target_settings" : attr .string_list (
1157- mandatory = False ,
1158- doc = """\
1159- A list of `config_setting` labels to add to the `target_settings` of every
1160- toolchain registered by this module extension. This is useful for creating
1161- separate "families" of toolchains gated behind custom build settings.
1162-
1163- For example, to ensure the default prebuilt toolchains are only resolved when
1164- a `prebuilt` config setting is active:
1165-
1166- ```starlark
1167- python.override(
1168- toolchain_target_settings = ["@@//:python_toolchain_family_prebuilt"],
1169- )
1170- ```
1171-
1172- These settings are appended to the `target_settings` of all toolchains
1173- registered by the extension, including any that already have settings
1174- from `python.single_version_platform_override`.
1175-
1176- :::{versionadded} VERSION_NEXT_FEATURE
1177- :::
1178- """ ,
1179- ),
11801180 } | AUTH_ATTRS ,
11811181)
11821182
0 commit comments