@@ -118,6 +118,7 @@ def _python_repository_impl(rctx):
118
118
python_version = rctx .attr .python_version
119
119
python_version_info = python_version .split ("." )
120
120
python_short_version = "{0}.{1}" .format (* python_version_info )
121
+ free_threading_postfix = "t" if rctx .attr .free_threading else ""
121
122
release_filename = rctx .attr .release_filename
122
123
urls = rctx .attr .urls or [rctx .attr .url ]
123
124
auth = get_auth (rctx , urls )
@@ -369,7 +370,7 @@ cc_library(
369
370
hdrs = [":includes"],
370
371
includes = [
371
372
"include",
372
- "include/python{python_version}",
373
+ "include/python{python_version}{ft_postfix} ",
373
374
"include/python{python_version}m",
374
375
],
375
376
)
@@ -378,9 +379,9 @@ cc_library(
378
379
name = "libpython",
379
380
hdrs = [":includes"],
380
381
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"],
384
385
}}),
385
386
)
386
387
@@ -432,6 +433,7 @@ py_exec_tools_toolchain(
432
433
python_path = python_bin ,
433
434
python_version = python_short_version ,
434
435
python_version_nodot = python_short_version .replace ("." , "" ),
436
+ ft_postfix = free_threading_postfix ,
435
437
coverage_attr = coverage_attr_text ,
436
438
interpreter_version_info_major = python_version_info [0 ],
437
439
interpreter_version_info_minor = python_version_info [1 ],
@@ -507,6 +509,11 @@ For more information see the official bazel docs
507
509
"Either distutils or distutils_content can be specified, but not both." ,
508
510
mandatory = False ,
509
511
),
512
+ "free_threading" : attr .bool (
513
+ default = False ,
514
+ doc = "Whether python interpreter has enabled free-threading (no GIL) mode." ,
515
+ mandatory = False ,
516
+ ),
510
517
"ignore_root_user_error" : attr .bool (
511
518
default = False ,
512
519
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
555
562
default = "1.5.2" ,
556
563
),
557
564
"_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
-
564
565
},
565
566
environ = [REPO_DEBUG_ENV_VAR ],
566
567
)
0 commit comments