Skip to content

Commit fee7a72

Browse files
committed
Added free_threading option to adapt python headers and library to free threading (no GIL) mode
1 parent 425dfb0 commit fee7a72

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

python/private/python_repositories.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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.",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy