@@ -27,7 +27,8 @@ def define_hermetic_runtime_toolchain_impl(
27
27
extra_files_glob_exclude ,
28
28
python_version ,
29
29
python_bin ,
30
- coverage_tool ):
30
+ coverage_tool ,
31
+ free_threading = False ):
31
32
"""Define a toolchain implementation for a python-build-standalone repo.
32
33
33
34
It expected this macro is called in the top-level package of an extracted
@@ -44,13 +45,17 @@ def define_hermetic_runtime_toolchain_impl(
44
45
python_version: {type}`str` The Python version, in `major.minor.micro`
45
46
format.
46
47
python_bin: {type}`str` The path to the Python binary within the
47
- repositoroy .
48
+ repository .
48
49
coverage_tool: {type}`str` optional target to the coverage tool to
49
50
use.
51
+ free_threading: {type}`bool` optional free-threading support.
52
+ Default, False.
50
53
"""
51
54
_ = name # @unused
52
55
version_info = semver (python_version )
53
56
version_dict = version_info .to_dict ()
57
+ version_dict ["ft_postfix" ] = "t" if free_threading else ""
58
+
54
59
native .filegroup (
55
60
name = "files" ,
56
61
srcs = native .glob (
@@ -67,19 +72,19 @@ def define_hermetic_runtime_toolchain_impl(
67
72
"**/* *" , # Bazel does not support spaces in file names.
68
73
# Unused shared libraries. `python` executable and the `:libpython` target
69
74
# 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 ),
71
76
# static libraries
72
77
"lib/**/*.a" ,
73
78
# 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 ),
76
81
"**/__pycache__/*.pyc.*" , # During pyc creation, temp files named *.pyc.NNN are created
77
82
] + extra_files_glob_exclude ,
78
83
),
79
84
)
80
85
cc_import (
81
86
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 ),
83
88
system_provided = True ,
84
89
)
85
90
@@ -96,7 +101,7 @@ def define_hermetic_runtime_toolchain_impl(
96
101
hdrs = [":includes" ],
97
102
includes = [
98
103
"include" ,
99
- "include/python{major}.{minor}" .format (** version_dict ),
104
+ "include/python{major}.{minor}{ft_postfix} " .format (** version_dict ),
100
105
"include/python{major}.{minor}m" .format (** version_dict ),
101
106
],
102
107
)
@@ -105,11 +110,11 @@ def define_hermetic_runtime_toolchain_impl(
105
110
hdrs = [":includes" ],
106
111
srcs = select ({
107
112
"@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 ),
110
115
],
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 )],
113
118
}),
114
119
)
115
120
0 commit comments