@@ -302,14 +302,9 @@ def _python_impl(module_ctx):
302302 # list of structs; see inline struct call within the loop below.
303303 toolchain_impls = []
304304
305- # list[str] of the base names of toolchain repos
306305 # list[str] of the repo names for host compatible repos
307306 all_host_compatible_repo_names = []
308307
309- # todo: The 3.13.1-custom-runtime ends up _last_ in the toolchain
310- # ordering, so it never gets picked.
311- # Need to move it first
312-
313308 # Create the underlying python_repository repos that contain the
314309 # python runtimes and their toolchain implementation definitions.
315310 for i , toolchain_info in enumerate (py .toolchains ):
@@ -329,7 +324,6 @@ def _python_impl(module_ctx):
329324 kwargs .update (py .config .kwargs .get (toolchain_info .python_version , {}))
330325 kwargs .update (py .config .kwargs .get (full_python_version , {}))
331326 kwargs .update (py .config .default )
332-
333327 register_result = python_register_toolchains (
334328 name = toolchain_info .name ,
335329 _internal_bzlmod_toolchain_call = True ,
@@ -367,18 +361,14 @@ def _python_impl(module_ctx):
367361 all_host_compatible_impls .setdefault (full_python_version , []).append (
368362 host_compat_entry ,
369363 )
364+ parsed_version = version .parse (full_python_version )
370365 all_host_compatible_impls .setdefault (
371- full_python_version . rpartition ( "." )[ 0 ] ,
366+ "{}.{}" . format ( * parsed_version . release [ 0 : 2 ]) ,
372367 [],
373368 ).append (host_compat_entry )
374369
375370 host_repo_name = toolchain_info .name + "_host"
376- if not host_platforms :
377- needed_host_repos [host_repo_name ] = struct (
378- compatible_version = toolchain_info .python_version ,
379- full_python_version = full_python_version ,
380- )
381- else :
371+ if host_platforms :
382372 all_host_compatible_repo_names .append (host_repo_name )
383373 host_platforms = sorted_host_platforms (host_platforms )
384374 entries = host_platforms .values ()
@@ -393,6 +383,11 @@ def _python_impl(module_ctx):
393383 python_versions = {str (i ): e .full_python_version for i , e in enumerate (entries )},
394384 impl_repo_names = {str (i ): e .impl_repo_name for i , e in enumerate (entries )},
395385 )
386+ else :
387+ needed_host_repos [host_repo_name ] = struct (
388+ compatible_version = toolchain_info .python_version ,
389+ full_python_version = full_python_version ,
390+ )
396391
397392 if needed_host_repos :
398393 for key , entries in all_host_compatible_impls .items ():
0 commit comments