diff --git a/.cirrus.yml b/.cirrus.yml index 8e19e50ff..9edd4d6cf 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -2,11 +2,11 @@ only_if: changesInclude('.cirrus.yml') || ($CIRRUS_BRANCH == "main" && !changesI run_tests: &RUN_TESTS install_cibuildwheel_script: + - python -V - python -m pip install -e ".[dev]" pytest-custom-exit-code run_cibuildwheel_tests_script: - python ./bin/run_tests.py - linux_x86_task: timeout_in: 120m compute_engine_instance: @@ -15,9 +15,14 @@ linux_x86_task: platform: linux cpu: 8 memory: 8G - + env: + VENV_ROOT: ${HOME}/venv-cibuildwheel + PATH: ${VENV_ROOT}/bin:${PATH} install_pre_requirements_script: - - 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: @@ -28,9 +33,14 @@ linux_aarch64_task: platform: linux cpu: 4 memory: 4G - + env: + VENV_ROOT: ${HOME}/venv-cibuildwheel + PATH: ${VENV_ROOT}/bin:${PATH} install_pre_requirements_script: - - 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: @@ -43,7 +53,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 @@ -51,22 +61,24 @@ windows_x86_task: macos_arm64_task: macos_instance: image: ghcr.io/cirruslabs/macos-sonoma-xcode - 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-sonoma-xcode - 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 496448eb0..ef3d3c621 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,10 +38,10 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-13, macos-14] - python_version: ['3.12'] + python_version: ['3.13'] include: - os: ubuntu-latest - python_version: '3.8' + python_version: '3.11' timeout-minutes: 180 steps: - uses: actions/checkout@v4 @@ -49,6 +49,7 @@ jobs: name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} + allow-prereleases: true - uses: yezz123/setup-uv@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 908d26fcd..c882c04f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,9 +24,9 @@ repos: rev: v1.11.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 - nox diff --git a/.travis.yml b/.travis.yml index 3dd6f9a8b..7dd90f788 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,21 +8,21 @@ 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 virt: vm env: PYTHON=python - - 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 @@ -32,16 +32,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 env: PYTHON=python diff --git a/CI.md b/CI.md index 2c082e940..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 | AppVeyor¹ / Azure Pipelines / GitHub Actions | Travis CI | Cirrus CI | | CircleCI¹ / GitHub Actions / GitLab¹ | -| macOS | AppVeyor¹ / Azure Pipelines | | Cirrus CI | GitLab¹ | CircleCI¹ / GitHub Actions | -| Windows | AppVeyor¹ / Azure Pipelines | Travis CI | Cirrus CI | | 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/appveyor.yml b/appveyor.yml index 4f12790da..2dd413f3b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,18 +1,18 @@ environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu - APPVEYOR_JOB_NAME: "python38-x64-ubuntu" + APPVEYOR_JOB_NAME: "python312-x64-ubuntu" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_JOB_NAME: "python38-x64-vs2015" + APPVEYOR_JOB_NAME: "python312-x64-vs2015" - APPVEYOR_BUILD_WORKER_IMAGE: macos - APPVEYOR_JOB_NAME: "python38-x64-macos" + APPVEYOR_JOB_NAME: "python312-x64-macos" -stack: python 3.8 +stack: python 3.12 build: off init: -- cmd: set PATH=C:\Python38;C:\Python38\Scripts;%PATH% +- cmd: set PATH=C:\Python312;C:\Python312\Scripts;%PATH% - ps: | $BRANCH = if ($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH) { $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH } else { $env:APPVEYOR_REPO_BRANCH } if (-not ($BRANCH -eq 'main' -or $BRANCH.ToLower().StartsWith('appveyor-'))) { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index beb3d80d7..5caf65ff3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,34 +5,34 @@ 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: | python -m pip install -e ".[dev]" 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 -e ".[dev]" 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 -e ".[dev]" python ./bin/run_tests.py 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 fc69cf63d..480e1714e 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 733eae017..2c9f3e213 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 05bae73e0..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__ = ( - "assert_never", - "NotRequired", - "Self", -) diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index 75def59c5..e50f5b9a5 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 1974588ca..3a6fab1ff 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -3,15 +3,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 @@ -94,7 +94,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 312e2f559..1d3a6ffc3 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 75be2023b..db8938e32 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -11,13 +11,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 @@ -49,7 +48,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) @@ -73,10 +72,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 0a5fa3250..85003e7e0 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -14,9 +14,8 @@ 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, Self -from ._compat.typing import Self from .typing import PathOrStr, PopenBytes from .util import ( CIProvider, @@ -398,7 +397,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 cb3606798..9e5a841c4 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -9,15 +9,22 @@ import functools import shlex import textwrap -from collections.abc import Callable, Generator, Iterable, Iterator, Set +import tomllib +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, NotRequired, TypedDict, assert_never from packaging.specifiers import SpecifierSet from . import errors -from ._compat import tomllib -from ._compat.typing import NotRequired, assert_never from .architecture import Architecture from .environment import EnvironmentParseError, ParsedEnvironment, parse_environment from .logger import log @@ -118,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) @@ -259,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 @@ -842,7 +849,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/projectfiles.py b/cibuildwheel/projectfiles.py index c1a376696..f8b0588e4 100644 --- a/cibuildwheel/projectfiles.py +++ b/cibuildwheel/projectfiles.py @@ -3,10 +3,9 @@ import ast import configparser import contextlib +import tomllib from pathlib import Path -from ._compat import tomllib - def get_parent(node: ast.AST | None, depth: int = 1) -> ast.AST | None: for _ in range(depth): diff --git a/cibuildwheel/typing.py b/cibuildwheel/typing.py index 61e1c96f9..b732d50c2 100644 --- a/cibuildwheel/typing.py +++ b/cibuildwheel/typing.py @@ -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]"] diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 555a914c7..a9d1d0670 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -13,13 +13,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 +from functools import cache from pathlib import Path, PurePath from tempfile import TemporaryDirectory from time import sleep @@ -35,14 +36,12 @@ from packaging.version import Version from platformdirs import user_cache_path -from ._compat import tomllib from .architecture import Architecture from .typing import PathOrStr, PlatformName __all__ = [ "MANYLINUX_ARCHS", "call", - "chdir", "combine_constraints", "find_compatible_wheel", "find_uv", @@ -564,7 +563,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: @@ -596,7 +595,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]}" @@ -772,19 +771,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 1651fecb7..8050c050a 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 44b4856a6..0006e0886 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ version = "2.19.2" 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 :: Implementation :: CPython", @@ -44,9 +41,7 @@ dependencies = [ "certifi", "filelock", "packaging>=20.9", - "platformdirs", - "tomli;python_version < '3.11'", - "typing-extensions>=4.1.0;python_version < '3.11'", + "platformdirs" ] [project.optional-dependencies] @@ -102,7 +97,7 @@ log_cli_level = "info" [tool.mypy] -python_version = "3.8" +python_version = "3.11" files = [ "cibuildwheel/*.py", "test/**/*.py", @@ -147,7 +142,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" @@ -184,7 +179,7 @@ messages_control.disable = [ ] [tool.ruff] -target-version = "py38" +target-version = "py311" line-length = 100 @@ -220,7 +215,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] @@ -229,14 +223,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 72329ec16..8984304af 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 5da5928c0..2c993b035 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/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index acd37c1bc..979dc9d1b 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/validate_schema_test.py b/unit_test/validate_schema_test.py index 698353990..25dc2c347 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()