From d52123ef1c20f8c8c86e07e00e80d9a35597c369 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 9 Jun 2024 10:55:15 +0200 Subject: [PATCH] chore: use SPEC 0 schedule for cibuildwheel --- .cirrus.yml | 35 +++++++++++++++-------- .github/workflows/test.yml | 2 +- .pre-commit-config.yaml | 8 +++--- .travis.yml | 22 +++++++------- CI.md | 12 ++++---- azure-pipelines.yml | 12 ++++---- bin/bump_version.py | 6 +--- bin/update_nodejs.py | 3 +- bin/update_pythons.py | 6 ++-- bin/update_virtualenv.py | 3 +- cibuildwheel/__main__.py | 7 ++--- cibuildwheel/_compat/__init__.py | 1 - cibuildwheel/_compat/tomllib.py | 10 ------- cibuildwheel/_compat/typing.py | 14 --------- cibuildwheel/architecture.py | 3 +- cibuildwheel/bashlex_eval.py | 10 +++++-- cibuildwheel/linux.py | 6 ++-- cibuildwheel/logger.py | 4 +-- cibuildwheel/macos.py | 9 +++--- cibuildwheel/oci_container.py | 5 ++-- cibuildwheel/options.py | 17 ++++++----- cibuildwheel/typing.py | 2 +- cibuildwheel/util.py | 22 +++----------- cibuildwheel/windows.py | 6 ++-- pyproject.toml | 19 +++--------- test/conftest.py | 2 +- test/test_projects/base.py | 6 ++-- unit_test/build_ids_test.py | 3 +- unit_test/get_platform_test.py | 9 +++--- unit_test/main_tests/main_options_test.py | 2 +- unit_test/projectfiles_test.py | 2 +- unit_test/validate_schema_test.py | 3 +- 32 files changed, 112 insertions(+), 159 deletions(-) delete mode 100644 cibuildwheel/_compat/__init__.py delete mode 100644 cibuildwheel/_compat/tomllib.py delete mode 100644 cibuildwheel/_compat/typing.py diff --git a/.cirrus.yml b/.cirrus.yml index 6faa9bf56..6c13ee1a7 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -7,7 +7,6 @@ run_tests: &RUN_TESTS run_cibuildwheel_tests_script: - python ./bin/run_tests.py - linux_x86_task: timeout_in: 120m compute_engine_instance: @@ -16,10 +15,15 @@ linux_x86_task: platform: linux cpu: 8 memory: 8G - + env: + VENV_ROOT: ${HOME}/venv-cibuildwheel + PATH: ${VENV_ROOT}/bin:${PATH} install_pre_requirements_script: - docker run --rm --privileged docker.io/tonistiigi/binfmt:latest --install all - - apt install -y python3-venv python-is-python3 + - add-apt-repository -y ppa:deadsnakes/ppa + - apt-get update + - apt-get install -y python3.12-venv + - python3.12 -m venv ${VENV_ROOT} <<: *RUN_TESTS linux_aarch64_task: @@ -30,10 +34,15 @@ linux_aarch64_task: platform: linux cpu: 4 memory: 4G - + env: + VENV_ROOT: ${HOME}/venv-cibuildwheel + PATH: ${VENV_ROOT}/bin:${PATH} install_pre_requirements_script: - docker run --rm --privileged docker.io/tonistiigi/binfmt:latest --install all - - apt install -y python3-venv python-is-python3 + - add-apt-repository -y ppa:deadsnakes/ppa + - apt-get update + - apt-get install -y python3.12-venv + - python3.12 -m venv ${VENV_ROOT} <<: *RUN_TESTS windows_x86_task: @@ -46,7 +55,7 @@ windows_x86_task: memory: 8G install_pre_requirements_script: - - choco install -y --no-progress python3 --version 3.10.6 + - choco install -y --no-progress python3 --version 3.12.4 - refreshenv - echo PATH=%PATH% >> "%CIRRUS_ENV%" <<: *RUN_TESTS @@ -54,22 +63,24 @@ windows_x86_task: macos_arm64_task: macos_instance: image: ghcr.io/cirruslabs/macos-runner:sonoma - env: - PATH: /opt/homebrew/opt/python@3.10/libexec/bin:$PATH + VENV_ROOT: ${HOME}/venv-cibuildwheel + PATH: ${VENV_ROOT}/bin:${PATH} install_pre_requirements_script: - - brew install python@3.10 + - brew install python@3.12 + - python3.12 -m venv ${VENV_ROOT} <<: *RUN_TESTS macos_arm64_cp38_task: macos_instance: image: ghcr.io/cirruslabs/macos-runner:sonoma - env: - PATH: /opt/homebrew/opt/python@3.10/libexec/bin:$PATH + VENV_ROOT: ${HOME}/venv-cibuildwheel + PATH: ${VENV_ROOT}/bin:${PATH} PYTEST_ADDOPTS: --run-cp38-universal2 -k 'test_cp38_arm64_testing_universal2_installer or test_arch_auto' install_pre_requirements_script: - - brew install python@3.10 + - brew install python@3.12 + - python3.12 -m venv ${VENV_ROOT} - curl -fsSLO https://www.python.org/ftp/python/3.8.10/python-3.8.10-macos11.pkg - sudo installer -pkg python-3.8.10-macos11.pkg -target / - rm python-3.8.10-macos11.pkg diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3ae2f604..667f40680 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: python_version: ['3.13'] include: - os: ubuntu-latest - python_version: '3.8' + python_version: '3.11' timeout-minutes: 180 steps: - uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c0e3e99c..73cc7c189 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,9 +24,9 @@ repos: rev: v1.13.0 hooks: - id: mypy - name: mypy 3.8 on cibuildwheel/ + name: mypy 3.11 on cibuildwheel/ exclude: ^cibuildwheel/resources/.*py|bin/generate_schema.py$ - args: ["--python-version=3.8"] + args: ["--python-version=3.11"] additional_dependencies: &mypy-dependencies - bracex - dependency-groups>=1.2 @@ -47,9 +47,9 @@ repos: - uv - validate-pyproject - id: mypy - name: mypy 3.12 + name: mypy 3.13 exclude: ^cibuildwheel/resources/.*py$ - args: ["--python-version=3.12"] + args: ["--python-version=3.13"] additional_dependencies: *mypy-dependencies - repo: https://github.com/shellcheck-py/shellcheck-py diff --git a/.travis.yml b/.travis.yml index b610edf00..808459794 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,13 @@ branches: jobs: include: - - name: Linux | x86_64 + i686 | Python 3.9 - python: 3.9 + - name: Linux | x86_64 + i686 | Python 3.11 + python: 3.11 services: docker env: PYTHON=python - - name: Linux | arm64 | Python 3.9 - python: 3.9 + - name: Linux | arm64 | Python 3.11 + python: 3.11 services: docker arch: arm64-graviton2 group: edge @@ -29,8 +29,8 @@ jobs: packages: - docker-ce docker-ce-cli containerd.io - - name: Linux | ppc64le | Python 3.9 - python: 3.9 + - name: Linux | ppc64le | Python 3.11 + python: 3.11 services: docker arch: ppc64le allow_failure: True @@ -40,16 +40,16 @@ jobs: # c.f. https://travis-ci.community/t/running-out-of-disk-space-quota-when-using-docker-on-ppc64le/11634 - PYTEST_ADDOPTS='-k "not test_manylinuxXXXX_only"' - - name: Windows | x86_64 | Python 3.9 + - name: Windows | x86_64 | Python 3.11 os: windows language: shell before_install: - - choco upgrade python3 -y --version 3.9.13 --limit-output --params "/InstallDir:C:\\Python39" + - choco upgrade python3 -y --version 3.11.9 --limit-output --params "/InstallDir:C:\\Python311" env: - - PYTHON=C:\\Python39\\python + - PYTHON=C:\\Python311\\python - - name: Linux | s390x | Python 3.9 - python: 3.9 + - name: Linux | s390x | Python 3.11 + python: 3.11 services: docker arch: s390x allow_failure: True diff --git a/CI.md b/CI.md index 25b001bf9..15de33c53 100644 --- a/CI.md +++ b/CI.md @@ -1,11 +1,11 @@ This is a summary of the host Python versions and platforms covered by the different CI platforms: -| | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 | -|---------|----------------------------------|-----------|-----------|---------|--------------------------------------------------| -| Linux | Azure Pipelines / GitHub Actions | Travis CI | Cirrus CI | | AppVeyor¹ / CircleCI¹ / GitHub Actions / GitLab¹ | -| macOS | Azure Pipelines | | Cirrus CI | GitLab¹ | AppVeyor¹ /CircleCI¹ / GitHub Actions | -| Windows | Azure Pipelines | Travis CI | Cirrus CI | | AppVeyor¹ / GitHub Actions / GitLab¹ | +| | 3.11 | 3.12 | 3.13 | +|---------|----------------------------------------------|---------------------------------------------|----------------| +| Linux | Azure Pipelines / GitHub Actions / Travis CI | AppVeyor¹ / CircleCI¹ / Cirrus CI / GitLab¹ | GitHub Actions | +| macOS | Azure Pipelines / GitLab¹ | AppVeyor¹ / CircleCI¹ / Cirrus CI / GitLab¹ | GitHub Actions | +| Windows | Azure Pipelines / Travis CI | AppVeyor¹ / Cirrus CI / GitLab¹ | GitHub Actions | > ¹ Runs a reduced set of tests to reduce CI load -Non-x86 architectures are covered on Travis CI using Python 3.9. +Non-x86 architectures are covered on Travis CI using Python 3.11. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fa720d84a..2586fb831 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,37 +5,37 @@ pr: - .pre-commit-config.yaml jobs: -- job: linux_38 +- job: linux_311 timeoutInMinutes: 120 pool: {vmImage: 'Ubuntu-20.04'} steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.11' - bash: | docker run --rm --privileged docker.io/tonistiigi/binfmt:latest --install all python -m pip install dependency-groups python -m dependency_groups test | xargs python -m pip install -e. python ./bin/run_tests.py -- job: macos_38 +- job: macos_311 pool: {vmImage: 'macOS-12'} steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.11' - bash: | python -m pip install dependency-groups python -m dependency_groups test | xargs python -m pip install -e. python ./bin/run_tests.py --num-processes 2 -- job: windows_38 +- job: windows_311 pool: {vmImage: 'windows-2019'} timeoutInMinutes: 180 steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.11' - bash: | python -m pip install dependency-groups python -m dependency_groups test | xargs python -m pip install -e. diff --git a/bin/bump_version.py b/bin/bump_version.py index e28bdcb97..2c56caff7 100755 --- a/bin/bump_version.py +++ b/bin/bump_version.py @@ -11,17 +11,13 @@ import os import subprocess import sys +import tomllib import urllib.parse from pathlib import Path import click from packaging.version import InvalidVersion, Version -if sys.version_info < (3, 11): - import tomli as tomllib -else: - import tomllib - config = [ # file path, version find/replace format ("pyproject.toml", 'version = "{}"'), diff --git a/bin/update_nodejs.py b/bin/update_nodejs.py index c2cb1c0f0..8a08274ae 100755 --- a/bin/update_nodejs.py +++ b/bin/update_nodejs.py @@ -4,6 +4,7 @@ import difflib import logging +import tomllib from dataclasses import dataclass from pathlib import Path from typing import Final @@ -16,8 +17,6 @@ from rich.logging import RichHandler from rich.syntax import Syntax -from cibuildwheel._compat import tomllib - log = logging.getLogger("cibw") # Looking up the dir instead of using utils.resources_dir diff --git a/bin/update_pythons.py b/bin/update_pythons.py index ecf8e3ef2..5921b427b 100755 --- a/bin/update_pythons.py +++ b/bin/update_pythons.py @@ -5,9 +5,10 @@ import copy import difflib import logging +import tomllib 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 @@ -17,7 +18,6 @@ from rich.logging import RichHandler from rich.syntax import Syntax -from cibuildwheel._compat import tomllib from cibuildwheel.extra import dump_python_configurations log = logging.getLogger("cibw") @@ -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 diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index b458c3f89..dffdb2561 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -5,6 +5,7 @@ import difflib import logging import subprocess +import tomllib from dataclasses import dataclass from pathlib import Path from typing import Final @@ -15,8 +16,6 @@ from rich.logging import RichHandler from rich.syntax import Syntax -from cibuildwheel._compat import tomllib - log = logging.getLogger("cibw") # Looking up the dir instead of using utils.resources_dir diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index ffdde57bf..ba580d5c3 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -1,6 +1,7 @@ from __future__ import annotations import argparse +import contextlib import dataclasses import os import shutil @@ -12,7 +13,7 @@ from collections.abc import Iterable, Sequence, Set from pathlib import Path from tempfile import mkdtemp -from typing import Protocol +from typing import Protocol, assert_never import cibuildwheel import cibuildwheel.linux @@ -21,7 +22,6 @@ import cibuildwheel.util import cibuildwheel.windows from cibuildwheel import errors -from cibuildwheel._compat.typing import assert_never from cibuildwheel.architecture import Architecture, allowed_architectures_check from cibuildwheel.logger import log from cibuildwheel.options import CommandLineArguments, Options, compute_options @@ -31,7 +31,6 @@ BuildSelector, CIProvider, Unbuffered, - chdir, detect_ci_provider, fix_ansi_codes_for_github_actions, strtobool, @@ -200,7 +199,7 @@ def main_inner(global_options: GlobalOptions) -> None: # This is now the new package dir args.package_dir = project_dir.resolve() - with chdir(project_dir): + with contextlib.chdir(project_dir): build_in_directory(args) finally: # avoid https://github.com/python/cpython/issues/86962 by performing diff --git a/cibuildwheel/_compat/__init__.py b/cibuildwheel/_compat/__init__.py deleted file mode 100644 index 9d48db4f9..000000000 --- a/cibuildwheel/_compat/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import annotations diff --git a/cibuildwheel/_compat/tomllib.py b/cibuildwheel/_compat/tomllib.py deleted file mode 100644 index b061ba911..000000000 --- a/cibuildwheel/_compat/tomllib.py +++ /dev/null @@ -1,10 +0,0 @@ -from __future__ import annotations - -import sys - -if sys.version_info >= (3, 11): - from tomllib import load, loads -else: - from tomli import load, loads - -__all__ = ["load", "loads"] diff --git a/cibuildwheel/_compat/typing.py b/cibuildwheel/_compat/typing.py deleted file mode 100644 index eb11302ab..000000000 --- a/cibuildwheel/_compat/typing.py +++ /dev/null @@ -1,14 +0,0 @@ -from __future__ import annotations - -import sys - -if sys.version_info < (3, 11): - from typing_extensions import NotRequired, Self, assert_never -else: - from typing import NotRequired, Self, assert_never - -__all__ = ( - "NotRequired", - "Self", - "assert_never", -) diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index 0f622def9..444d37017 100644 --- a/cibuildwheel/architecture.py +++ b/cibuildwheel/architecture.py @@ -6,9 +6,8 @@ import sys from collections.abc import Set from enum import Enum -from typing import Final, Literal +from typing import Final, Literal, assert_never -from ._compat.typing import assert_never from .typing import PlatformName PRETTY_NAMES: Final[dict[PlatformName, str]] = { diff --git a/cibuildwheel/bashlex_eval.py b/cibuildwheel/bashlex_eval.py index c5f805372..749665394 100644 --- a/cibuildwheel/bashlex_eval.py +++ b/cibuildwheel/bashlex_eval.py @@ -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: diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 1ffe96f9a..d4bac7bb5 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -4,15 +4,15 @@ 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 typing import assert_never from packaging.version import Version from . import errors -from ._compat.typing import assert_never from .architecture import Architecture from .logger import log from .oci_container import OCIContainer, OCIContainerEngineConfig, OCIPlatform @@ -104,7 +104,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) diff --git a/cibuildwheel/logger.py b/cibuildwheel/logger.py index 542576076..b88093814 100644 --- a/cibuildwheel/logger.py +++ b/cibuildwheel/logger.py @@ -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]"), diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index fcc88dac9..bea0a25d8 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -12,13 +12,12 @@ from collections.abc import Sequence, Set from dataclasses import dataclass from pathlib import Path -from typing import Literal, Tuple +from typing import Literal, assert_never from filelock import FileLock from packaging.version import Version from . import errors -from ._compat.typing import assert_never from .architecture import Architecture from .environment import ParsedEnvironment from .logger import log @@ -50,7 +49,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) @@ -74,10 +73,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): diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 646bbc643..3e4e6ada5 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -16,9 +16,8 @@ from enum import Enum from pathlib import Path, PurePath, PurePosixPath from types import TracebackType -from typing import IO, Dict, Literal +from typing import IO, Literal, Self, assert_never -from ._compat.typing import Self, assert_never from .errors import OCIEngineTooOldError from .logger import log from .typing import PathOrStr, PopenBytes @@ -489,7 +488,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 diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 3fb9ebb73..5192a2587 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -9,15 +9,14 @@ import functools import shlex import textwrap -from collections.abc import Generator, Iterable, Set +import tomllib +from collections.abc import Generator, Iterable, Mapping, Sequence, Set from pathlib import Path -from typing import Any, Literal, Mapping, Sequence, Union # noqa: TID251 +from typing import Any, Literal, assert_never from packaging.specifiers import SpecifierSet from . import errors -from ._compat import tomllib -from ._compat.typing import assert_never from .architecture import Architecture from .environment import EnvironmentParseError, ParsedEnvironment, parse_environment from .logger import log @@ -121,10 +120,10 @@ def architectures(self) -> set[Architecture]: return self.globals.architectures -SettingLeaf = Union[str, int, bool] +SettingLeaf = str | int | bool SettingList = Sequence[SettingLeaf] -SettingTable = Mapping[str, Union[SettingLeaf, SettingList]] -SettingValue = Union[SettingTable, SettingList, SettingLeaf] +SettingTable = Mapping[str, SettingLeaf | SettingList] +SettingValue = SettingTable | SettingList | SettingLeaf @dataclasses.dataclass(frozen=True) @@ -359,7 +358,7 @@ def _stringify_setting( msg = f"Error converting {setting!r} to a string: this setting doesn't accept a list" raise OptionsReaderError(msg) from None - if isinstance(setting, (bool, int)): + if isinstance(setting, bool | int): return str(setting) return setting @@ -976,7 +975,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. diff --git a/cibuildwheel/typing.py b/cibuildwheel/typing.py index 367cfcdf1..34ae273c8 100644 --- a/cibuildwheel/typing.py +++ b/cibuildwheel/typing.py @@ -15,7 +15,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]"] diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 905dd5410..b2a598030 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -14,13 +14,14 @@ import tarfile import textwrap import time +import tomllib import typing import urllib.request from collections import defaultdict from collections.abc import Generator, Iterable, Mapping, MutableMapping, Sequence from dataclasses import dataclass from enum import Enum -from functools import lru_cache, total_ordering +from functools import cache, total_ordering from pathlib import Path, PurePath from tempfile import TemporaryDirectory from time import sleep @@ -36,7 +37,6 @@ from packaging.version import Version from platformdirs import user_cache_path -from ._compat import tomllib from .architecture import Architecture from .errors import FatalError from .typing import PathOrStr, PlatformName @@ -45,7 +45,6 @@ "MANYLINUX_ARCHS", "EnableGroups", "call", - "chdir", "combine_constraints", "find_compatible_wheel", "find_uv", @@ -596,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: @@ -628,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]}" @@ -804,19 +803,6 @@ def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> T | None: return None -# Can be replaced by contextlib.chdir in Python 3.11 -@contextlib.contextmanager -def chdir(new_path: Path | str) -> Generator[None, None, None]: - """Non thread-safe context manager to change the current working directory.""" - - cwd = os.getcwd() - try: - os.chdir(new_path) - yield - finally: - os.chdir(cwd) - - def fix_ansi_codes_for_github_actions(text: str) -> str: """ Github Actions forgets the current ANSI style on every new line. This diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 8f5633d67..c88430dee 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -7,14 +7,14 @@ 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 typing import assert_never from filelock import FileLock from packaging.version import Version from . import errors -from ._compat.typing import assert_never from .architecture import Architecture from .environment import ParsedEnvironment from .logger import log @@ -96,7 +96,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"): diff --git a/pyproject.toml b/pyproject.toml index 3b0d72d1f..42b903fb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ version = "2.22.0" description = "Build Python wheels on CI with minimal configuration." readme = "README.md" license = "BSD-2-Clause" -requires-python = ">=3.8" +requires-python = ">=3.11" authors = [ { name = "Joe Rickerby", email = "joerick@mac.com" }, ] @@ -30,9 +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", "Programming Language :: Python :: 3.13", @@ -46,9 +43,7 @@ dependencies = [ "dependency-groups>=1.2", "filelock", "packaging>=20.9", - "platformdirs", - "tomli;python_version < '3.11'", - "typing-extensions>=4.1.0;python_version < '3.11'", + "platformdirs" ] [project.optional-dependencies] @@ -109,7 +104,7 @@ log_cli_level = "info" [tool.mypy] -python_version = "3.8" +python_version = "3.11" files = [ "cibuildwheel/*.py", "test/**/*.py", @@ -141,7 +136,7 @@ ignore_missing_imports = true [tool.pylint] -py-version = "3.8" +py-version = "3.11" jobs = "0" fail-on = ["E", "F"] fail-under = "9.8" @@ -211,7 +206,6 @@ ignore = [ "PYI025", # Set as AbstractSet "ISC001", # Conflicts with formatter ] -typing-modules = ["cibuildwheel._compat.typing"] flake8-unused-arguments.ignore-variadic-names = true [tool.ruff.lint.flake8-tidy-imports.banned-api] @@ -220,14 +214,9 @@ flake8-unused-arguments.ignore-variadic-names = true "typing.Iterator".msg = "Use collections.abc.Iterator instead." "typing.Sequence".msg = "Use collections.abc.Sequence instead." "typing.Set".msg = "Use collections.abc.Set instead." -"typing.NotRequired".msg = "Use cibuildwheel._compat.typing.NotRequired instead." -"typing.assert_never".msg = "Use cibuildwheel._compat.typing.assert_never instead." -"tomllib".msg = "Use cibuildwheel._compat.tomllib instead." -"tomli".msg = "Use cibuildwheel._compat.tomllib instead." [tool.ruff.lint.per-file-ignores] "unit_test/*" = ["PLC1901"] -"cibuildwheel/_compat/**.py" = ["TID251"] "bin/*" = ["TID251"] [tool.repo-review] diff --git a/test/conftest.py b/test/conftest.py index a42a3ce9a..42a0d9acf 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,7 +2,7 @@ import json import subprocess -from typing import Generator +from collections.abc import Generator import pytest diff --git a/test/test_projects/base.py b/test/test_projects/base.py index d7a9305a5..99ccc8b33 100644 --- a/test/test_projects/base.py +++ b/test/test_projects/base.py @@ -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: diff --git a/unit_test/build_ids_test.py b/unit_test/build_ids_test.py index a42af93de..0a444e85c 100644 --- a/unit_test/build_ids_test.py +++ b/unit_test/build_ids_test.py @@ -1,8 +1,9 @@ from __future__ import annotations +import tomllib + from packaging.version import Version -from cibuildwheel._compat import tomllib from cibuildwheel.extra import Printable, dump_python_configurations from cibuildwheel.util import resources_dir diff --git a/unit_test/get_platform_test.py b/unit_test/get_platform_test.py index dfcc7d87b..c9c312e50 100644 --- a/unit_test/get_platform_test.py +++ b/unit_test/get_platform_test.py @@ -1,7 +1,6 @@ import contextlib import sys from pathlib import Path -from typing import Dict import pytest import setuptools._distutils.util @@ -16,7 +15,7 @@ @contextlib.contextmanager -def patched_environment(monkeypatch: pytest.MonkeyPatch, environment: Dict[str, str]): +def patched_environment(monkeypatch: pytest.MonkeyPatch, environment: dict[str, str]): with monkeypatch.context() as mp: for envvar, val in environment.items(): mp.setenv(name=envvar, value=val) @@ -25,7 +24,7 @@ def patched_environment(monkeypatch: pytest.MonkeyPatch, environment: Dict[str, def test_x86(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): arch = "32" - environment: Dict[str, str] = {} + environment: dict[str, str] = {} configuration = PythonConfiguration("irrelevant", arch, "irrelevant", None) @@ -39,7 +38,7 @@ def test_x86(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): def test_x64(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): arch = "64" - environment: Dict[str, str] = {} + environment: dict[str, str] = {} configuration = PythonConfiguration("irrelevant", arch, "irrelevant", None) @@ -56,7 +55,7 @@ def test_x64(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): ) def test_arm(tmp_path: Path, monkeypatch: pytest.MonkeyPatch): arch = "ARM64" - environment: Dict[str, str] = {} + environment: dict[str, str] = {} configuration = PythonConfiguration("irrelevant", arch, "irrelevant", None) diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 849dbe3ba..e93f32ea5 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -1,13 +1,13 @@ from __future__ import annotations import sys +import tomllib from fnmatch import fnmatch from pathlib import Path import pytest from cibuildwheel.__main__ import main -from cibuildwheel._compat import tomllib from cibuildwheel.environment import ParsedEnvironment from cibuildwheel.options import BuildOptions, _get_pinned_container_images from cibuildwheel.util import BuildSelector, resources_dir, split_config_settings diff --git a/unit_test/projectfiles_test.py b/unit_test/projectfiles_test.py index 179f648ef..77ea78cf1 100644 --- a/unit_test/projectfiles_test.py +++ b/unit_test/projectfiles_test.py @@ -1,10 +1,10 @@ from __future__ import annotations +import tomllib from textwrap import dedent import pytest -from cibuildwheel._compat import tomllib from cibuildwheel.projectfiles import ( get_requires_python_str, resolve_dependency_groups, diff --git a/unit_test/validate_schema_test.py b/unit_test/validate_schema_test.py index bb102bb25..c0dfad454 100644 --- a/unit_test/validate_schema_test.py +++ b/unit_test/validate_schema_test.py @@ -1,13 +1,12 @@ from __future__ import annotations import re +import tomllib from pathlib import Path import pytest import validate_pyproject.api -from cibuildwheel._compat import tomllib - DIR = Path(__file__).parent.resolve()