Skip to content

Commit

Permalink
fix: update Python update script to process beta versions
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed May 19, 2021
1 parent 53f66d3 commit 139e240
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ What does it do?
- Bundles shared library dependencies on Linux and macOS through [auditwheel](https://github.com/pypa/auditwheel) and [delocate](https://github.com/matthew-brett/delocate)
- Runs your library's tests against the wheel-installed version of your library


See the [cibuildwheel 1 documentation](https://cibuildwheel.readthedocs.io/en/1.x/) if you need to build unsupported versions of Python, such as Python 2.

Usage
Expand Down
28 changes: 14 additions & 14 deletions bin/update_pythons.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import difflib
import logging
from pathlib import Path
from typing import Any, Union
from typing import Any, Iterable, Union, cast

import click
import requests
Expand Down Expand Up @@ -79,23 +79,22 @@ def __init__(self, arch_str: ArchStr) -> None:
response.raise_for_status()
cp_info = response.json()

versions = (Version(v) for v in cp_info["versions"])
self.versions = sorted(v for v in versions if not v.is_devrelease)
self.version_dict = {Version(v): v for v in cp_info["versions"]}

def update_version_windows(self, spec: Specifier) -> ConfigWinCP | None:
versions = sorted(v for v in self.versions if spec.contains(v))
if not all(v.is_prerelease for v in versions):
versions = [v for v in versions if not v.is_prerelease]
unsorted_versions = cast(Iterable[Version], spec.filter(self.version_dict))
versions = sorted(unsorted_versions, reverse=True)

log.debug(f"Windows {self.arch} {spec} has {', '.join(str(v) for v in versions)}")

if not versions:
return None

version = versions[-1]
version = versions[0]
identifier = f"cp{version.major}{version.minor}-{self.arch}"
return ConfigWinCP(
identifier=identifier,
version=str(version),
version=self.version_dict[version],
arch=self.arch_str,
)

Expand Down Expand Up @@ -190,21 +189,22 @@ def __init__(self) -> None:
# Removing the prefix, Python 3.9 would use: release["name"].removeprefix("Python ")
version = Version(release["name"][7:])

if not version.is_prerelease and not version.is_devrelease:
uri = int(release["resource_uri"].rstrip("/").split("/")[-1])
self.versions_dict[version] = uri
uri = int(release["resource_uri"].rstrip("/").split("/")[-1])
self.versions_dict[version] = uri

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))

unsorted_versions = cast(Iterable[Version], spec.filter(self.versions_dict))
sorted_versions = sorted(unsorted_versions, reverse=True)

if version <= Version("3.8.9999"):
file_ident = "macosx10.9.pkg"
else:
file_ident = "macos11.pkg"

for new_version in reversed(sorted_versions):
for new_version in sorted_versions:
# Find the first patch version that contains the requested file
uri = self.versions_dict[new_version]
response = requests.get(
Expand Down Expand Up @@ -273,7 +273,7 @@ def update_config(self, config: dict[str, str]) -> None:
@click.command()
@click.option("--force", is_flag=True)
@click.option(
"--level", default="INFO", type=click.Choice(["INFO", "DEBUG", "TRACE"], case_sensitive=False)
"--level", default="INFO", type=click.Choice(["WARNING", "INFO", "DEBUG"], case_sensitive=False)
)
def update_pythons(force: bool, level: str) -> None:

Expand Down
6 changes: 2 additions & 4 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,12 @@ def main() -> None:
) or get_requires_python_str(package_dir)
requires_python = None if requires_python_str is None else SpecifierSet(requires_python_str)

# Filters Python 3.10 unless --pre is passed
# Hardcode pre-releases here, current: Python 3.10
build_selector = BuildSelector(
build_config=build_config,
skip_config=skip_config,
requires_python=requires_python,
filter_prerelease=""
if args.pre
else "310", # hardcode pre-releases here, current: Python 3.10
filter_prerelease="" if args.pre else "310",
)
test_selector = TestSelector(skip_config=test_skip)

Expand Down

0 comments on commit 139e240

Please sign in to comment.