@@ -118,6 +118,7 @@ def _python_repository_impl(rctx):
118118    python_version  =  rctx .attr .python_version 
119119    python_version_info  =  python_version .split ("." )
120120    python_short_version  =  "{0}.{1}" .format (* python_version_info )
121+     free_threading_postfix  =  "t"  if  rctx .attr .free_threading  else  "" 
121122    release_filename  =  rctx .attr .release_filename 
122123    urls  =  rctx .attr .urls  or  [rctx .attr .url ]
123124    auth  =  get_auth (rctx , urls )
@@ -369,7 +370,7 @@ cc_library(
369370    hdrs = [":includes"], 
370371    includes = [ 
371372        "include", 
372-         "include/python{python_version}", 
373+         "include/python{python_version}{ft_postfix} ", 
373374        "include/python{python_version}m", 
374375    ], 
375376) 
@@ -378,9 +379,9 @@ cc_library(
378379    name = "libpython", 
379380    hdrs = [":includes"], 
380381    srcs = select({{ 
381-         "@platforms//os:windows": ["python3.dll", "libs/python{python_version_nodot}.lib"], 
382-         "@platforms//os:macos": ["lib/libpython{python_version}.dylib"], 
383-         "@platforms//os:linux": ["lib/libpython{python_version}.so", "lib/libpython{python_version}.so.1.0"], 
382+         "@platforms//os:windows": ["python3.dll", "libs/python{python_version_nodot}{ft_postfix} .lib"], 
383+         "@platforms//os:macos": ["lib/libpython{python_version}{ft_postfix} .dylib"], 
384+         "@platforms//os:linux": ["lib/libpython{python_version}{ft_postfix} .so", "lib/libpython{python_version}{ft_postfix }.so.1.0"], 
384385    }}), 
385386) 
386387
@@ -432,6 +433,7 @@ py_exec_tools_toolchain(
432433        python_path  =  python_bin ,
433434        python_version  =  python_short_version ,
434435        python_version_nodot  =  python_short_version .replace ("." , "" ),
436+         ft_postfix  =  free_threading_postfix ,
435437        coverage_attr  =  coverage_attr_text ,
436438        interpreter_version_info_major  =  python_version_info [0 ],
437439        interpreter_version_info_minor  =  python_version_info [1 ],
@@ -507,6 +509,11 @@ For more information see the official bazel docs
507509                  "Either distutils or distutils_content can be specified, but not both." ,
508510            mandatory  =  False ,
509511        ),
512+         "free_threading" : attr .bool (
513+             default  =  False ,
514+             doc  =  "Whether python interpreter has enabled free-threading (no GIL) mode." ,
515+             mandatory  =  False ,
516+         ),
510517        "ignore_root_user_error" : attr .bool (
511518            default  =  False ,
512519            doc  =  "Whether the check for root should be ignored or not. This causes cache misses with .pyc files." ,
@@ -555,12 +562,6 @@ For more information see the official bazel docs
555562            default  =  "1.5.2" ,
556563        ),
557564        "_rule_name" : attr .string (default  =  "python_repository" ),
558-         "free_threading" : attr .bool (
559-             default  =  False ,
560-             doc  =  "Whether python interpreter has enabled free-threading (no GIL) mode." ,
561-             mandatory  =  False ,
562-         ),
563- 
564565    },
565566    environ  =  [REPO_DEBUG_ENV_VAR ],
566567)
0 commit comments