From ada6c6495ea5be2b2a4a5395f341abe438b55247 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 8 May 2021 12:59:39 +0200 Subject: [PATCH] pin CPython 3.8 installer on macosx10.9 macosx11 installer requires macOS 11+ for CPython 3.8 while macosx11 installer for CPython 3.9+ only requires macOS 10.9+ on x86_64. --- bin/update_pythons.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/bin/update_pythons.py b/bin/update_pythons.py index 1b656ecc4..6a7c7a325 100755 --- a/bin/update_pythons.py +++ b/bin/update_pythons.py @@ -196,27 +196,32 @@ def __init__(self) -> None: uri = int(release["resource_uri"].rstrip("/").split("/")[-1]) self.versions_dict[version] = uri - def update_version_macos(self, identifier: str, spec: Specifier) -> ConfigMacOS | None: - file_idents = ("macos11.pkg", "macosx10.9.pkg", "macosx10.6.pkg") + def update_version_macos( + self, identifier: str, version: Version, spec: Specifier + ) -> ConfigMacOS | None: sorted_versions = sorted(v for v in self.versions_dict if spec.contains(v)) - for version in reversed(sorted_versions): + if version <= Version("3.8.9999"): + file_ident = "macosx10.9.pkg" + else: + file_ident = "macos11.pkg" + + for new_version in reversed(sorted_versions): # Find the first patch version that contains the requested file - uri = self.versions_dict[version] + uri = self.versions_dict[new_version] response = requests.get( f"https://www.python.org/api/v2/downloads/release_file/?release={uri}" ) response.raise_for_status() file_info = response.json() - for file_ident in file_idents: - urls = [rf["url"] for rf in file_info if file_ident in rf["url"]] - if urls: - return ConfigMacOS( - identifier=identifier, - version=f"{version.major}.{version.minor}", - url=urls[0], - ) + urls = [rf["url"] for rf in file_info if file_ident in rf["url"]] + if urls: + return ConfigMacOS( + identifier=identifier, + version=f"{new_version.major}.{new_version.minor}", + url=urls[0], + ) return None @@ -247,7 +252,7 @@ def update_config(self, config: dict[str, str]) -> None: if identifier.startswith("pp"): config_update = self.macos_pypy.update_version_macos(spec) else: - config_update = self.macos_cpython.update_version_macos(identifier, spec) + config_update = self.macos_cpython.update_version_macos(identifier, version, spec) assert config_update is not None, f"MacOS {spec} not found!" config.update(**config_update)