Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pin CPython 3.8 installer on macosx10.9 #664

Merged
merged 1 commit into from
May 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions bin/update_pythons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could instead take the old file identifier, and only look for that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but that's a possible update later to remove the explicit version check.


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

Expand Down Expand Up @@ -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)
Expand Down