diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 1ff447aa5..700535fed 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -7,6 +7,7 @@ import tarfile import textwrap import typing +from collections.abc import Sequence, Set from pathlib import Path from tempfile import mkdtemp @@ -18,7 +19,12 @@ from cibuildwheel.architecture import Architecture, allowed_architectures_check from cibuildwheel.logger import log from cibuildwheel.options import CommandLineArguments, Options, compute_options -from cibuildwheel.typing import PLATFORMS, PlatformName, assert_never +from cibuildwheel.typing import ( + PLATFORMS, + GenericPythonConfiguration, + PlatformName, + assert_never, +) from cibuildwheel.util import ( CIBW_CACHE_PATH, BuildSelector, @@ -339,13 +345,9 @@ def print_preamble(platform: str, options: Options, identifiers: list[str]) -> N def get_build_identifiers( - platform: PlatformName, build_selector: BuildSelector, architectures: set[Architecture] + platform: PlatformName, build_selector: BuildSelector, architectures: Set[Architecture] ) -> list[str]: - python_configurations: ( - list[cibuildwheel.linux.PythonConfiguration] - | list[cibuildwheel.windows.PythonConfiguration] - | list[cibuildwheel.macos.PythonConfiguration] - ) + python_configurations: Sequence[GenericPythonConfiguration] if platform == "linux": python_configurations = cibuildwheel.linux.get_python_configurations( diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index f5d8710e1..1a1f71037 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -3,6 +3,7 @@ import subprocess import sys import textwrap +from collections.abc import Set from dataclasses import dataclass from pathlib import Path, PurePath, PurePosixPath from typing import Iterator, Tuple @@ -46,7 +47,7 @@ class BuildStep: def get_python_configurations( build_selector: BuildSelector, - architectures: set[Architecture], + architectures: Set[Architecture], ) -> list[PythonConfiguration]: full_python_configs = read_python_configs("linux") diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 3bb1324db..6047b1eea 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -8,6 +8,7 @@ import shutil import subprocess import sys +from collections.abc import Set from dataclasses import dataclass from pathlib import Path from typing import Sequence, Tuple, cast @@ -69,7 +70,7 @@ class PythonConfiguration: def get_python_configurations( - build_selector: BuildSelector, architectures: set[Architecture] + build_selector: BuildSelector, architectures: Set[Architecture] ) -> list[PythonConfiguration]: full_python_configs = read_python_configs("macos") diff --git a/cibuildwheel/typing.py b/cibuildwheel/typing.py index 6c8fe9fc3..9374401cb 100644 --- a/cibuildwheel/typing.py +++ b/cibuildwheel/typing.py @@ -42,3 +42,9 @@ PlatformName = Literal["linux", "macos", "windows"] PLATFORMS: Final[set[PlatformName]] = {"linux", "macos", "windows"} + + +class GenericPythonConfiguration(Protocol): + @property + def identifier(self) -> str: + ... diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index cb83a324b..e0f16d815 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -6,6 +6,7 @@ import subprocess import sys import textwrap +from collections.abc import Set from dataclasses import dataclass from functools import lru_cache from pathlib import Path @@ -71,7 +72,7 @@ class PythonConfiguration: def get_python_configurations( build_selector: BuildSelector, - architectures: set[Architecture], + architectures: Set[Architecture], ) -> list[PythonConfiguration]: full_python_configs = read_python_configs("windows")