@@ -27,7 +27,8 @@ def define_hermetic_runtime_toolchain_impl(
2727 extra_files_glob_exclude ,
2828 python_version ,
2929 python_bin ,
30- coverage_tool ):
30+ coverage_tool ,
31+ free_threading = False ):
3132 """Define a toolchain implementation for a python-build-standalone repo.
3233
3334 It expected this macro is called in the top-level package of an extracted
@@ -44,13 +45,17 @@ def define_hermetic_runtime_toolchain_impl(
4445 python_version: {type}`str` The Python version, in `major.minor.micro`
4546 format.
4647 python_bin: {type}`str` The path to the Python binary within the
47- repositoroy .
48+ repository .
4849 coverage_tool: {type}`str` optional target to the coverage tool to
4950 use.
51+ free_threading: {type}`bool` optional free-threading support.
52+ Default, False.
5053 """
5154 _ = name # @unused
5255 version_info = semver (python_version )
5356 version_dict = version_info .to_dict ()
57+ version_dict ["ft_postfix" ] = "t" if free_threading else ""
58+
5459 native .filegroup (
5560 name = "files" ,
5661 srcs = native .glob (
@@ -67,19 +72,19 @@ def define_hermetic_runtime_toolchain_impl(
6772 "**/* *" , # Bazel does not support spaces in file names.
6873 # Unused shared libraries. `python` executable and the `:libpython` target
6974 # depend on `libpython{python_version}.so.1.0`.
70- "lib/libpython{major}.{minor}.so" .format (** version_dict ),
75+ "lib/libpython{major}.{minor}{ft_postfix} .so" .format (** version_dict ),
7176 # static libraries
7277 "lib/**/*.a" ,
7378 # tests for the standard libraries.
74- "lib/python{major}.{minor}/**/test/**" .format (** version_dict ),
75- "lib/python{major}.{minor}/**/tests/**" .format (** version_dict ),
79+ "lib/python{major}.{minor}{ft_postfix} /**/test/**" .format (** version_dict ),
80+ "lib/python{major}.{minor}{ft_postfix} /**/tests/**" .format (** version_dict ),
7681 "**/__pycache__/*.pyc.*" , # During pyc creation, temp files named *.pyc.NNN are created
7782 ] + extra_files_glob_exclude ,
7883 ),
7984 )
8085 cc_import (
8186 name = "interface" ,
82- interface_library = "libs/python{major}{minor}.lib" .format (** version_dict ),
87+ interface_library = "libs/python{major}{minor}{ft_postfix} .lib" .format (** version_dict ),
8388 system_provided = True ,
8489 )
8590
@@ -96,7 +101,7 @@ def define_hermetic_runtime_toolchain_impl(
96101 hdrs = [":includes" ],
97102 includes = [
98103 "include" ,
99- "include/python{major}.{minor}" .format (** version_dict ),
104+ "include/python{major}.{minor}{ft_postfix} " .format (** version_dict ),
100105 "include/python{major}.{minor}m" .format (** version_dict ),
101106 ],
102107 )
@@ -105,11 +110,11 @@ def define_hermetic_runtime_toolchain_impl(
105110 hdrs = [":includes" ],
106111 srcs = select ({
107112 "@platforms//os:linux" : [
108- "lib/libpython{major}.{minor}.so" .format (** version_dict ),
109- "lib/libpython{major}.{minor}.so.1.0" .format (** version_dict ),
113+ "lib/libpython{major}.{minor}{ft_postfix} .so" .format (** version_dict ),
114+ "lib/libpython{major}.{minor}{ft_postfix} .so.1.0" .format (** version_dict ),
110115 ],
111- "@platforms//os:macos" : ["lib/libpython{major}.{minor}.dylib" .format (** version_dict )],
112- "@platforms//os:windows" : ["python3.dll" , "libs/python{major}{minor}.lib" .format (** version_dict )],
116+ "@platforms//os:macos" : ["lib/libpython{major}.{minor}{ft_postfix} .dylib" .format (** version_dict )],
117+ "@platforms//os:windows" : ["python3.dll" , "libs/python{major}{minor}{ft_postfix} .lib" .format (** version_dict )],
113118 }),
114119 )
115120
0 commit comments