Skip to content

Commit

Permalink
chore: use SPEC 0 schedule for cibuildwheel
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Jun 22, 2024
1 parent 8bda260 commit 47287d4
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
python_version: ['3.12']
include:
- os: ubuntu-latest
python_version: '3.8'
python_version: '3.10'
timeout-minutes: 180
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ repos:
rev: v1.10.0
hooks:
- id: mypy
name: mypy 3.8 on cibuildwheel/
name: mypy 3.10 on cibuildwheel/
exclude: ^cibuildwheel/resources/.*py|bin/generate_schema.py$
args: ["--python-version=3.8"]
args: ["--python-version=3.10"]
additional_dependencies: &mypy-dependencies
- bracex
- nox
Expand Down
4 changes: 2 additions & 2 deletions bin/update_pythons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from collections.abc import Mapping, MutableMapping
from pathlib import Path
from typing import Any, Final, Literal, TypedDict, Union
from typing import Any, Final, Literal, TypedDict

import click
import requests
Expand Down Expand Up @@ -50,7 +50,7 @@ class ConfigMacOS(TypedDict):
url: str


AnyConfig = Union[ConfigWinCP, ConfigWinPP, ConfigMacOS]
AnyConfig = ConfigWinCP | ConfigWinPP | ConfigMacOS


# The following set of "Versions" classes allow the initial call to the APIs to
Expand Down
10 changes: 7 additions & 3 deletions cibuildwheel/bashlex_eval.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from __future__ import annotations

import subprocess
from collections.abc import Iterable, Mapping, Sequence
from collections.abc import (
Callable,
Iterable,
Mapping,
Sequence,
)
from dataclasses import dataclass
from typing import Callable, Dict, List # noqa: TID251

import bashlex

# a function that takes a command and the environment, and returns the result
EnvironmentExecutor = Callable[[List[str], Dict[str, str]], str]
EnvironmentExecutor = Callable[[list[str], dict[str, str]], str]


def local_environment_executor(command: Sequence[str], env: Mapping[str, str]) -> str:
Expand Down
4 changes: 2 additions & 2 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import subprocess
import sys
import textwrap
from collections import OrderedDict
from collections.abc import Iterable, Iterator, Sequence, Set
from dataclasses import dataclass
from pathlib import Path, PurePath, PurePosixPath
from typing import OrderedDict, Tuple

from packaging.version import Version

Expand Down Expand Up @@ -96,7 +96,7 @@ def get_build_steps(
Groups PythonConfigurations into BuildSteps. Each BuildStep represents a
separate container instance.
"""
steps = OrderedDict[Tuple[str, str, str, OCIContainerEngineConfig], BuildStep]()
steps = OrderedDict[tuple[str, str, str, OCIContainerEngineConfig], BuildStep]()

for config in python_configurations:
_, platform_tag = config.identifier.split("-", 1)
Expand Down
4 changes: 2 additions & 2 deletions cibuildwheel/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import re
import sys
import time
from typing import IO, AnyStr, Final, Tuple
from typing import IO, AnyStr, Final

from .util import CIProvider, detect_ci_provider

FoldPattern = Tuple[str, str]
FoldPattern = tuple[str, str]
DEFAULT_FOLD_PATTERN: Final[FoldPattern] = ("{name}", "")
FOLD_PATTERNS: Final[dict[str, FoldPattern]] = {
"azure": ("##[group]{name}", "##[endgroup]"),
Expand Down
8 changes: 4 additions & 4 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections.abc import Sequence, Set
from dataclasses import dataclass
from pathlib import Path
from typing import Literal, Tuple
from typing import Literal

from filelock import FileLock
from packaging.version import Version
Expand Down Expand Up @@ -51,7 +51,7 @@
)


@functools.lru_cache(maxsize=None)
@functools.cache
def get_macos_version() -> tuple[int, int]:
"""
Returns the macOS major/minor version, as a tuple, e.g. (10, 15) or (11, 0)
Expand All @@ -75,10 +75,10 @@ def get_macos_version() -> tuple[int, int]:
capture_stdout=True,
)
version = tuple(map(int, version_str.split(".")[:2]))
return typing.cast(Tuple[int, int], version)
return typing.cast(tuple[int, int], version)


@functools.lru_cache(maxsize=None)
@functools.cache
def get_test_macosx_deployment_target() -> str:
version = get_macos_version()
if version >= (11, 0):
Expand Down
4 changes: 2 additions & 2 deletions cibuildwheel/oci_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass, field
from pathlib import Path, PurePath, PurePosixPath
from types import TracebackType
from typing import IO, Dict, Literal
from typing import IO, Literal

from ._compat.typing import Self
from .typing import PathOrStr, PopenBytes
Expand Down Expand Up @@ -398,7 +398,7 @@ def get_environment(self) -> dict[str, str]:
capture_output=True,
)
)
return typing.cast(Dict[str, str], env)
return typing.cast(dict[str, str], env)

def environment_executor(self, command: Sequence[str], environment: dict[str, str]) -> str:
# used as an EnvironmentExecutor to evaluate commands and capture output
Expand Down
18 changes: 13 additions & 5 deletions cibuildwheel/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
import functools
import shlex
import textwrap
from collections.abc import Callable, Generator, Iterable, Iterator, Set
from collections.abc import (
Callable,
Generator,
Iterable,
Iterator,
Mapping,
Sequence,
Set,
)
from pathlib import Path
from typing import Any, Literal, Mapping, Sequence, TypedDict, Union # noqa: TID251
from typing import Any, Literal, TypedDict

from packaging.specifiers import SpecifierSet

Expand Down Expand Up @@ -117,7 +125,7 @@ def architectures(self) -> set[Architecture]:
return self.globals.architectures


Setting = Union[Mapping[str, str], Sequence[str], str, int, bool]
Setting = Mapping[str, str] | Sequence[str] | str | int | bool


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -258,7 +266,7 @@ def _stringify_setting(
raise ConfigOptionError(msg)
return list_sep.join(setting)

if isinstance(setting, (bool, int)):
if isinstance(setting, bool | int):
return str(setting)

return setting
Expand Down Expand Up @@ -838,7 +846,7 @@ def compute_options(
return options


@functools.lru_cache(maxsize=None)
@functools.cache
def _get_pinned_container_images() -> Mapping[str, Mapping[str, str]]:
"""
This looks like a dict of dicts, e.g.
Expand Down
2 changes: 1 addition & 1 deletion cibuildwheel/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

if typing.TYPE_CHECKING:
PopenBytes = subprocess.Popen[bytes]
PathOrStr = Union[str, os.PathLike[str]]
PathOrStr = str | os.PathLike[str]
else:
PopenBytes = subprocess.Popen
PathOrStr = Union[str, "os.PathLike[str]"]
Expand Down
6 changes: 3 additions & 3 deletions cibuildwheel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from collections.abc import Generator, Iterable, Mapping, MutableMapping, Sequence
from dataclasses import dataclass
from enum import Enum
from functools import lru_cache
from functools import cache
from pathlib import Path, PurePath
from tempfile import TemporaryDirectory
from time import sleep
Expand Down Expand Up @@ -595,7 +595,7 @@ def get_pip_version(env: Mapping[str, str]) -> str:
return pip_version


@lru_cache(maxsize=None)
@cache
def ensure_node(major_version: str) -> Path:
input_file = resources_dir / "nodejs.toml"
with input_file.open("rb") as f:
Expand Down Expand Up @@ -627,7 +627,7 @@ def ensure_node(major_version: str) -> Path:
return path


@lru_cache(maxsize=None)
@cache
def _ensure_virtualenv(version: str) -> Path:
version_parts = version.split(".")
key = f"py{version_parts[0]}{version_parts[1]}"
Expand Down
4 changes: 2 additions & 2 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import textwrap
from collections.abc import MutableMapping, Sequence, Set
from dataclasses import dataclass
from functools import lru_cache
from functools import cache
from pathlib import Path

from filelock import FileLock
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_python_configurations(
return python_configurations


@lru_cache(maxsize=None)
@cache
def _ensure_nuget() -> Path:
nuget = CIBW_CACHE_PATH / "nuget.exe"
with FileLock(str(nuget) + ".lock"):
Expand Down
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "2.19.1"
description = "Build Python wheels on CI with minimal configuration."
readme = "README.md"
license = "BSD-2-Clause"
requires-python = ">=3.8"
requires-python = ">=3.10"
authors = [
{ name = "Joe Rickerby", email = "joerick@mac.com" },
]
Expand All @@ -30,8 +30,6 @@ classifiers = [
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down Expand Up @@ -106,7 +104,7 @@ log_cli_level = "info"


[tool.mypy]
python_version = "3.8"
python_version = "3.10"
files = [
"cibuildwheel/*.py",
"test/**/*.py",
Expand Down Expand Up @@ -149,7 +147,7 @@ ignore_missing_imports = true


[tool.pylint]
py-version = "3.8"
py-version = "3.10"
jobs = "0"
fail-on = ["E", "F"]
fail-under = "9.8"
Expand Down Expand Up @@ -186,7 +184,7 @@ messages_control.disable = [
]

[tool.ruff]
target-version = "py38"
target-version = "py310"
line-length = 100


Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
import subprocess
from typing import Generator
from collections.abc import Generator

import pytest

Expand Down
6 changes: 3 additions & 3 deletions test/test_projects/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

from pathlib import Path
from typing import Any, Dict, Union
from typing import Any

import jinja2

FilesDict = Dict[str, Union[str, jinja2.Template]]
TemplateContext = Dict[str, Any]
FilesDict = dict[str, str | jinja2.Template]
TemplateContext = dict[str, Any]


class TestProject:
Expand Down

0 comments on commit 47287d4

Please sign in to comment.