@@ -35,7 +35,13 @@ If the value is missing, then the default value is being used, see documentation
3535# access it, but it's not intended for general public usage.
3636_NOT_ACTUALLY_PUBLIC = ["//visibility:public" ]
3737
38- def construct_config_settings (* , name , default_version , versions , minor_mapping , documented_flags ): # buildifier: disable=function-docstring
38+ def construct_config_settings (
39+ * ,
40+ name ,
41+ default_version ,
42+ versions ,
43+ minor_mapping ,
44+ documented_flags ): # buildifier: disable=function-docstring
3945 """Create a 'python_version' config flag and construct all config settings used in rules_python.
4046
4147 This mainly includes the targets that are used in the toolchain and pip hub
@@ -109,13 +115,29 @@ def construct_config_settings(*, name, default_version, versions, minor_mapping,
109115 # It's private because matching the concept of e.g. "3.8" value is done
110116 # using the `is_python_X.Y` config setting group, which is aware of the
111117 # minor versions that could match instead.
118+ first_minor = None
112119 for minor in minor_mapping .keys ():
120+ if first_minor == None :
121+ first_minor = minor
122+
113123 native .config_setting (
114124 name = "is_python_{}" .format (minor ),
115125 flag_values = {_PYTHON_VERSION_MAJOR_MINOR_FLAG : minor },
116126 visibility = ["//visibility:public" ],
117127 )
118128
129+ for minor in range (int (first_minor .partition ("." )[- 1 ]) + 1 ):
130+ minor = "3.{}" .format (minor )
131+ if minor in minor_mapping :
132+ break
133+
134+ # TODO @aignas 2025-11-04: use env-marker-setting with the smallest minor_mapping version
135+ native .alias (
136+ name = "is_python_{}" .format (minor ),
137+ actual = "@platforms//:incompatible" ,
138+ visibility = ["//visibility:public" ],
139+ )
140+
119141 _current_config (
120142 name = "current_config" ,
121143 build_setting_default = "" ,
0 commit comments