Skip to content

Commit c53ada9

Browse files
committed
chore: add freethreaded interpreters to 3.13 def
1 parent ae0aeff commit c53ada9

File tree

3 files changed

+180
-119
lines changed

3 files changed

+180
-119
lines changed

python/config_settings/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ string_flag(
9292
visibility = ["//visibility:public"],
9393
)
9494

95+
string_flag(
96+
name = "py_freethreaded",
97+
build_setting_default = "no",
98+
values = [
99+
"yes",
100+
"no",
101+
],
102+
visibility = ["//visibility:public"],
103+
)
104+
95105
# pip.parse related flags
96106

97107
string_flag(

python/private/toolchains_repo.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ def _get_host_platform(os_name, arch):
390390
"""
391391
host_platform = None
392392
for platform, meta in PLATFORMS.items():
393+
if "freethreaded" in platform:
394+
continue
395+
393396
if meta.os_name == os_name and meta.arch == arch:
394397
host_platform = platform
395398
if not host_platform:

python/versions.bzl

Lines changed: 167 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,27 @@ TOOL_VERSIONS = {
561561
"strip_prefix": "python",
562562
},
563563
"3.13.0": {
564-
"url": "20241008/cpython-{python_version}+20241008-{platform}-{build}.tar.gz",
564+
"url": {
565+
platform + suffix: "20241008/cpython-{python_version}+20241008-" + build
566+
for platform, opt in {
567+
"aarch64-apple-darwin": "pgo+lto",
568+
"aarch64-unknown-linux-gnu": "lto",
569+
"ppc64le-unknown-linux-gnu": "lto",
570+
"s390x-unknown-linux-gnu": "lto",
571+
"x86_64-apple-darwin": "pgo+lto",
572+
"x86_64-pc-windows-msvc": "pgo",
573+
"x86_64-unknown-linux-gnu": "pgo+lto",
574+
}.items()
575+
for suffix, build in {
576+
"": platform + "-{build}.tar.gz",
577+
"-freethreaded": "".join([
578+
platform,
579+
"-shared" if "windows" in platform else "",
580+
"-freethreaded+" + opt,
581+
"-full.tar.zst",
582+
]),
583+
}.items()
584+
},
565585
"sha256": {
566586
"aarch64-apple-darwin": "5d3cb8d7ca4cfbbe7ae1f118f26be112ee417d982fab8c6d85cfd8ccccf70718",
567587
"aarch64-unknown-linux-gnu": "c1142af8f2c85923d2ba8201a35b913bb903a5d15f052c38bbecf2f49e2342dc",
@@ -570,6 +590,14 @@ TOOL_VERSIONS = {
570590
"x86_64-apple-darwin": "b58ca12d9ae14bbd79f9e5cf4b748211ff1953e59abeac63b0f4e8e49845669f",
571591
"x86_64-pc-windows-msvc": "c7651a7a575104f47c808902b020168057f3ad80f277e54cecfaf79a9ff50e22",
572592
"x86_64-unknown-linux-gnu": "455200e1a202e9d9ef4b630c04af701c0a91dcaa6462022efc76893fc762ec95",
593+
# Add freethreaded variants
594+
"aarch64-apple-darwin-freethreaded": "8cc1586c4ee730bb33b7e6d39f1b6388f895075fadb1771e3c27b0561abb9242",
595+
"aarch64-unknown-linux-gnu-freethreaded": "56b11e29095e7c183ae191bf9f5ec4e7a71ac41e9c759786faf16c707b83b6b0",
596+
"ppc64le-unknown-linux-gnu-freethreaded": "abac77abeb3c39c355fbc2cd74216254c46bcb28dda10b525daf821bf1d364dc",
597+
"s390x-unknown-linux-gnu-freethreaded": "9adab574543ab8c5fc0ad9e313050030dbdae85160629b1dcbbc3e9d9515a0da",
598+
"x86_64-apple-darwin-freethreaded": "117528b68096379b1303faee1f4f9e32ef3d255207ec92fb063f1bd0b942549d",
599+
"x86_64-pc-windows-msvc-freethreaded": "fc665561556f4dc843cd3eeba4d482f716aec65d5b89a657316829cfbdc9462a",
600+
"x86_64-unknown-linux-gnu-freethreaded": "00a159a64640ce614bdac064b270a9854d86d40d1d8387a822daf1fe0881e64b",
573601
},
574602
"strip_prefix": "python",
575603
},
@@ -586,121 +614,135 @@ MINOR_MAPPING = {
586614
}
587615

588616
PLATFORMS = {
589-
"aarch64-apple-darwin": struct(
590-
compatible_with = [
591-
"@platforms//os:macos",
592-
"@platforms//cpu:aarch64",
593-
],
594-
flag_values = {},
595-
os_name = MACOS_NAME,
596-
# Matches the value returned from:
597-
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
598-
arch = "arm64",
599-
),
600-
"aarch64-unknown-linux-gnu": struct(
601-
compatible_with = [
602-
"@platforms//os:linux",
603-
"@platforms//cpu:aarch64",
604-
],
605-
flag_values = {
606-
Label("//python/config_settings:py_linux_libc"): "glibc",
607-
},
608-
os_name = LINUX_NAME,
609-
# Note: this string differs between OSX and Linux
610-
# Matches the value returned from:
611-
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
612-
arch = "aarch64",
613-
),
614-
"armv7-unknown-linux-gnu": struct(
615-
compatible_with = [
616-
"@platforms//os:linux",
617-
"@platforms//cpu:armv7",
618-
],
619-
flag_values = {
620-
Label("//python/config_settings:py_linux_libc"): "glibc",
621-
},
622-
os_name = LINUX_NAME,
623-
arch = "armv7",
624-
),
625-
"i386-unknown-linux-gnu": struct(
626-
compatible_with = [
627-
"@platforms//os:linux",
628-
"@platforms//cpu:i386",
629-
],
630-
flag_values = {
631-
Label("//python/config_settings:py_linux_libc"): "glibc",
632-
},
633-
os_name = LINUX_NAME,
634-
arch = "i386",
635-
),
636-
"ppc64le-unknown-linux-gnu": struct(
637-
compatible_with = [
638-
"@platforms//os:linux",
639-
"@platforms//cpu:ppc",
640-
],
641-
flag_values = {
642-
Label("//python/config_settings:py_linux_libc"): "glibc",
643-
},
644-
os_name = LINUX_NAME,
645-
# Note: this string differs between OSX and Linux
646-
# Matches the value returned from:
647-
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
648-
arch = "ppc64le",
649-
),
650-
"riscv64-unknown-linux-gnu": struct(
651-
compatible_with = [
652-
"@platforms//os:linux",
653-
"@platforms//cpu:riscv64",
654-
],
617+
p + suffix: struct(
618+
compatible_with = v.compatible_with,
655619
flag_values = {
656-
Label("//python/config_settings:py_linux_libc"): "glibc",
657-
},
658-
os_name = LINUX_NAME,
659-
arch = "riscv64",
660-
),
661-
"s390x-unknown-linux-gnu": struct(
662-
compatible_with = [
663-
"@platforms//os:linux",
664-
"@platforms//cpu:s390x",
665-
],
666-
flag_values = {
667-
Label("//python/config_settings:py_linux_libc"): "glibc",
668-
},
669-
os_name = LINUX_NAME,
670-
# Note: this string differs between OSX and Linux
671-
# Matches the value returned from:
672-
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
673-
arch = "s390x",
674-
),
675-
"x86_64-apple-darwin": struct(
676-
compatible_with = [
677-
"@platforms//os:macos",
678-
"@platforms//cpu:x86_64",
679-
],
680-
flag_values = {},
681-
os_name = MACOS_NAME,
682-
arch = "x86_64",
683-
),
684-
"x86_64-pc-windows-msvc": struct(
685-
compatible_with = [
686-
"@platforms//os:windows",
687-
"@platforms//cpu:x86_64",
688-
],
689-
flag_values = {},
690-
os_name = WINDOWS_NAME,
691-
arch = "x86_64",
692-
),
693-
"x86_64-unknown-linux-gnu": struct(
694-
compatible_with = [
695-
"@platforms//os:linux",
696-
"@platforms//cpu:x86_64",
697-
],
698-
flag_values = {
699-
Label("//python/config_settings:py_linux_libc"): "glibc",
700-
},
701-
os_name = LINUX_NAME,
702-
arch = "x86_64",
703-
),
620+
Label("//python/config_settings:py_freethreaded"): freethreaded,
621+
} | v.flag_values,
622+
os_name = v.os_name,
623+
arch = v.arch,
624+
)
625+
for p, v in {
626+
"aarch64-apple-darwin": struct(
627+
compatible_with = [
628+
"@platforms//os:macos",
629+
"@platforms//cpu:aarch64",
630+
],
631+
flag_values = {},
632+
os_name = MACOS_NAME,
633+
# Matches the value returned from:
634+
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
635+
arch = "arm64",
636+
),
637+
"aarch64-unknown-linux-gnu": struct(
638+
compatible_with = [
639+
"@platforms//os:linux",
640+
"@platforms//cpu:aarch64",
641+
],
642+
flag_values = {
643+
Label("//python/config_settings:py_linux_libc"): "glibc",
644+
},
645+
os_name = LINUX_NAME,
646+
# Note: this string differs between OSX and Linux
647+
# Matches the value returned from:
648+
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
649+
arch = "aarch64",
650+
),
651+
"armv7-unknown-linux-gnu": struct(
652+
compatible_with = [
653+
"@platforms//os:linux",
654+
"@platforms//cpu:armv7",
655+
],
656+
flag_values = {
657+
Label("//python/config_settings:py_linux_libc"): "glibc",
658+
},
659+
os_name = LINUX_NAME,
660+
arch = "armv7",
661+
),
662+
"i386-unknown-linux-gnu": struct(
663+
compatible_with = [
664+
"@platforms//os:linux",
665+
"@platforms//cpu:i386",
666+
],
667+
flag_values = {
668+
Label("//python/config_settings:py_linux_libc"): "glibc",
669+
},
670+
os_name = LINUX_NAME,
671+
arch = "i386",
672+
),
673+
"ppc64le-unknown-linux-gnu": struct(
674+
compatible_with = [
675+
"@platforms//os:linux",
676+
"@platforms//cpu:ppc",
677+
],
678+
flag_values = {
679+
Label("//python/config_settings:py_linux_libc"): "glibc",
680+
},
681+
os_name = LINUX_NAME,
682+
# Note: this string differs between OSX and Linux
683+
# Matches the value returned from:
684+
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
685+
arch = "ppc64le",
686+
),
687+
"riscv64-unknown-linux-gnu": struct(
688+
compatible_with = [
689+
"@platforms//os:linux",
690+
"@platforms//cpu:riscv64",
691+
],
692+
flag_values = {
693+
Label("//python/config_settings:py_linux_libc"): "glibc",
694+
},
695+
os_name = LINUX_NAME,
696+
arch = "riscv64",
697+
),
698+
"s390x-unknown-linux-gnu": struct(
699+
compatible_with = [
700+
"@platforms//os:linux",
701+
"@platforms//cpu:s390x",
702+
],
703+
flag_values = {
704+
Label("//python/config_settings:py_linux_libc"): "glibc",
705+
},
706+
os_name = LINUX_NAME,
707+
# Note: this string differs between OSX and Linux
708+
# Matches the value returned from:
709+
# repository_ctx.execute(["uname", "-m"]).stdout.strip()
710+
arch = "s390x",
711+
),
712+
"x86_64-apple-darwin": struct(
713+
compatible_with = [
714+
"@platforms//os:macos",
715+
"@platforms//cpu:x86_64",
716+
],
717+
flag_values = {},
718+
os_name = MACOS_NAME,
719+
arch = "x86_64",
720+
),
721+
"x86_64-pc-windows-msvc": struct(
722+
compatible_with = [
723+
"@platforms//os:windows",
724+
"@platforms//cpu:x86_64",
725+
],
726+
flag_values = {},
727+
os_name = WINDOWS_NAME,
728+
arch = "x86_64",
729+
),
730+
"x86_64-unknown-linux-gnu": struct(
731+
compatible_with = [
732+
"@platforms//os:linux",
733+
"@platforms//cpu:x86_64",
734+
],
735+
flag_values = {
736+
Label("//python/config_settings:py_linux_libc"): "glibc",
737+
},
738+
os_name = LINUX_NAME,
739+
arch = "x86_64",
740+
),
741+
}.items()
742+
for suffix, freethreaded in {
743+
"": "no",
744+
"-freethreaded": "yes",
745+
}.items()
704746
}
705747

706748
def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_URL, tool_versions = TOOL_VERSIONS):
@@ -760,6 +802,15 @@ def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_U
760802
return (release_filename, rendered_urls, strip_prefix, patches, patch_strip)
761803

762804
def print_toolchains_checksums(name):
805+
"""A macro to print checksums for a particular Python interpreter version.
806+
807+
Args:
808+
name: {type}`str`: the name of the runnable target.
809+
"""
810+
commands = []
811+
for python_version in TOOL_VERSIONS.keys():
812+
commands.append(_commands_for_version(python_version))
813+
763814
native.genrule(
764815
name = name,
765816
srcs = [],
@@ -775,10 +826,7 @@ echo "Fetching hashes..."
775826
{commands}
776827
EOF
777828
""".format(
778-
commands = "\n".join([
779-
_commands_for_version(python_version)
780-
for python_version in TOOL_VERSIONS.keys()
781-
]),
829+
commands = "\n".join(commands),
782830
),
783831
executable = True,
784832
)

0 commit comments

Comments
 (0)