Skip to content

Commit daaa4de

Browse files
committed
use a function to define platforms
1 parent 0f9954e commit daaa4de

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

python/versions.bzl

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
MACOS_NAME = "mac os"
2020
LINUX_NAME = "linux"
2121
WINDOWS_NAME = "windows"
22+
FREETHREADED = "freethreaded"
2223

2324
DEFAULT_RELEASE_BASE_URL = "https://github.com/indygreg/python-build-standalone/releases/download"
2425

@@ -612,16 +613,10 @@ MINOR_MAPPING = {
612613
"3.13": "3.13.0",
613614
}
614615

615-
PLATFORMS = {
616-
p + suffix: struct(
617-
compatible_with = v.compatible_with,
618-
flag_values = {
619-
Label("//python/config_settings:py_freethreaded"): freethreaded,
620-
} | v.flag_values,
621-
os_name = v.os_name,
622-
arch = v.arch,
623-
)
624-
for p, v in {
616+
def _generate_platforms():
617+
libc = Label("//python/config_settings:py_linux_libc")
618+
619+
platforms = {
625620
"aarch64-apple-darwin": struct(
626621
compatible_with = [
627622
"@platforms//os:macos",
@@ -639,7 +634,7 @@ PLATFORMS = {
639634
"@platforms//cpu:aarch64",
640635
],
641636
flag_values = {
642-
Label("//python/config_settings:py_linux_libc"): "glibc",
637+
libc: "glibc",
643638
},
644639
os_name = LINUX_NAME,
645640
# Note: this string differs between OSX and Linux
@@ -653,7 +648,7 @@ PLATFORMS = {
653648
"@platforms//cpu:armv7",
654649
],
655650
flag_values = {
656-
Label("//python/config_settings:py_linux_libc"): "glibc",
651+
libc: "glibc",
657652
},
658653
os_name = LINUX_NAME,
659654
arch = "armv7",
@@ -664,7 +659,7 @@ PLATFORMS = {
664659
"@platforms//cpu:i386",
665660
],
666661
flag_values = {
667-
Label("//python/config_settings:py_linux_libc"): "glibc",
662+
libc: "glibc",
668663
},
669664
os_name = LINUX_NAME,
670665
arch = "i386",
@@ -675,7 +670,7 @@ PLATFORMS = {
675670
"@platforms//cpu:ppc",
676671
],
677672
flag_values = {
678-
Label("//python/config_settings:py_linux_libc"): "glibc",
673+
libc: "glibc",
679674
},
680675
os_name = LINUX_NAME,
681676
# Note: this string differs between OSX and Linux
@@ -732,17 +727,32 @@ PLATFORMS = {
732727
"@platforms//cpu:x86_64",
733728
],
734729
flag_values = {
735-
Label("//python/config_settings:py_linux_libc"): "glibc",
730+
libc: "glibc",
736731
},
737732
os_name = LINUX_NAME,
738733
arch = "x86_64",
739734
),
740-
}.items()
741-
for suffix, freethreaded in {
742-
"": "no",
743-
"-freethreaded": "yes",
744-
}.items()
745-
}
735+
}
736+
737+
freethreaded = Label("//python/config_settings:py_freethreaded")
738+
return {
739+
p + suffix: struct(
740+
compatible_with = v.compatible_with,
741+
flag_values = {
742+
freethreaded: freethreaded_value,
743+
} | v.flag_values,
744+
os_name = v.os_name,
745+
arch = v.arch,
746+
)
747+
for suffix, freethreaded_value in {
748+
"": "no",
749+
"-freethreaded": "yes",
750+
}.items()
751+
for p, v in platforms.items()
752+
}
753+
754+
PLATFORMS = _generate_platforms(
755+
)
746756

747757
def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_URL, tool_versions = TOOL_VERSIONS):
748758
"""Resolve the release URL for the requested interpreter version

0 commit comments

Comments
 (0)