Files
tensorflow/third_party/py/rules_python_freethreaded.patch
Peter Hawkins 2cc70fff1e Bump rules_python to v2.2.0.
PiperOrigin-RevId: 962699045
2026-08-11 04:29:20 -07:00

70 lines
2.9 KiB
Diff

diff --git a/python/private/pypi/platform.bzl b/python/private/pypi/platform.bzl
index 00000000..00000000 100644
--- a/python/private/pypi/platform.bzl
+++ b/python/private/pypi/platform.bzl
@@ -25,7 +25,7 @@ def platform(*, name, arch_name, os_name, config_settings = [], env = {}, marker
# the lowest priority one needs to be the first one
whl_platform_tags = ["any"] + whl_platform_tags
- whl_abi_tags = whl_abi_tags or ["abi3", "cp{major}{minor}"]
+ whl_abi_tags = whl_abi_tags or ["abi3", "cp{major}{minor}", "cp{major}{minor}t"]
if "none" not in whl_abi_tags:
# the lowest priority one needs to be the first one
whl_abi_tags = ["none"] + whl_abi_tags
diff --git a/python/private/pypi/pep508_env.bzl b/python/private/pypi/pep508_env.bzl
index 00000000..00000000 100644
--- a/python/private/pypi/pep508_env.bzl
+++ b/python/private/pypi/pep508_env.bzl
@@ -23,6 +23,7 @@ _DEFAULT = "//conditions:default"
# Here we store the aliases in the platform so that the users can specify any valid target in
# there.
_cpu_aliases = {
+ "amd64": "x86_64",
"arm": "aarch32",
"arm64": "aarch64",
}
diff --git a/python/private/python_register_toolchains.bzl b/python/private/python_register_toolchains.bzl
index 9e75c419..ba6d8f7a 100644
--- a/python/private/python_register_toolchains.bzl
+++ b/python/private/python_register_toolchains.bzl
@@ -94,6 +94,7 @@ def python_register_toolchains(
minor_mapping = minor_mapping or MINOR_MAPPING
python_version = full_version(version = python_version, minor_mapping = minor_mapping)
+ python_version_kind = kwargs.pop("python_version_kind", "")
toolchain_repo_name = "{name}_toolchains".format(name = name)
@@ -174,6 +175,7 @@ def python_register_toolchains(
name = name + "_host",
platforms = loaded_platforms,
python_version = python_version,
+ python_version_kind = python_version_kind,
)
toolchains_repo(
diff --git a/python/private/toolchains_repo.bzl b/python/private/toolchains_repo.bzl
index f7ff19c3..458f2885 100644
--- a/python/private/toolchains_repo.bzl
+++ b/python/private/toolchains_repo.bzl
@@ -445,6 +445,10 @@ Full python version, Major.Minor.Micro.
Only set in workspace calls.
""",
),
+ "python_version_kind": attr.string(
+ doc = "Python version kind, e.g. ft (free-threaded)",
+ default = ""
+ ),
"python_versions": attr.string_dict(
doc = """
If set, the Python version for the corresponding selected platform. Values in
@@ -603,6 +607,9 @@ def _get_host_impl_repo_name(*, rctx, logger, python_version, os_name, cpu_name,
else:
candidates = [preference]
+ if rctx.attr.python_version_kind == "ft":
+ candidates = [c for c in candidates if c[0].endswith("freethreaded")]
+
if candidates:
platform_name, meta = candidates[0]
suffix = meta.impl_repo_name