Skip to content

Commit 66a102a

Browse files
committed
move the URL generation to a function instead of list comprehension
1 parent daaa4de commit 66a102a

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

python/versions.bzl

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -562,27 +562,7 @@ TOOL_VERSIONS = {
562562
"strip_prefix": "python",
563563
},
564564
"3.13.0": {
565-
"url": {
566-
platform + suffix: "20241016/cpython-{python_version}+20241016-" + build
567-
for platform, opt in {
568-
"aarch64-apple-darwin": "pgo+lto",
569-
"aarch64-unknown-linux-gnu": "lto",
570-
"ppc64le-unknown-linux-gnu": "lto",
571-
"s390x-unknown-linux-gnu": "lto",
572-
"x86_64-apple-darwin": "pgo+lto",
573-
"x86_64-pc-windows-msvc": "pgo",
574-
"x86_64-unknown-linux-gnu": "pgo+lto",
575-
}.items()
576-
for suffix, build in {
577-
"": platform + "-{build}.tar.gz",
578-
"-freethreaded": "".join([
579-
platform,
580-
"-shared" if "windows" in platform else "",
581-
"-freethreaded+" + opt,
582-
"-full.tar.zst",
583-
]),
584-
}.items()
585-
},
565+
"url": "20241016/cpython-{python_version}+20241016-{platform}-{build}.{ext}",
586566
"sha256": {
587567
"aarch64-apple-darwin": "31397953849d275aa2506580f3fa1cb5a85b6a3d392e495f8030e8b6412f5556",
588568
"aarch64-unknown-linux-gnu": "e8378c0162b2e0e4cc1f62b29443a3305d116d09583304dbb0149fecaff6347b",
@@ -751,8 +731,7 @@ def _generate_platforms():
751731
for p, v in platforms.items()
752732
}
753733

754-
PLATFORMS = _generate_platforms(
755-
)
734+
PLATFORMS = _generate_platforms()
756735

757736
def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_URL, tool_versions = TOOL_VERSIONS):
758737
"""Resolve the release URL for the requested interpreter version
@@ -782,10 +761,27 @@ def get_release_info(platform, python_version, base_url = DEFAULT_RELEASE_BASE_U
782761
release_filename = None
783762
rendered_urls = []
784763
for u in url:
764+
p, _, _ = platform.partition("-freethreaded")
765+
if "freethreaded" in platform:
766+
build = {
767+
"aarch64-apple-darwin": "freethreaded+pgo+lto-full",
768+
"aarch64-unknown-linux-gnu": "freethreaded+lto-full",
769+
"ppc64le-unknown-linux-gnu": "freethreaded+lto-full",
770+
"s390x-unknown-linux-gnu": "freethreaded+lto-full",
771+
"x86_64-apple-darwin": "freethreaded+pgo+lto-full",
772+
"x86_64-pc-windows-msvc": "shared-freethreaded+pgo-full",
773+
"x86_64-unknown-linux-gnu": "freethreaded+pgo+lto-full",
774+
}[p]
775+
ext = "tar.zst"
776+
else:
777+
build = "shared-install_only" if (WINDOWS_NAME in platform) else "install_only"
778+
ext = "tar.gz"
779+
785780
release_filename = u.format(
786-
platform = platform,
781+
platform = p,
787782
python_version = python_version,
788-
build = "shared-install_only" if (WINDOWS_NAME in platform) else "install_only",
783+
build = build,
784+
ext = ext,
789785
)
790786
if "://" in release_filename: # is absolute url?
791787
rendered_urls.append(release_filename)

0 commit comments

Comments
 (0)