chore: use from __future__ import annotations

This commit is contained in:
mayeut
2022-07-19 07:47:45 +02:00
parent 054230e01b
commit 6d27f05c7c
71 changed files with 285 additions and 166 deletions
+3
View File
@@ -18,6 +18,7 @@ repos:
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: ["--py37-plus"] args: ["--py37-plus"]
exclude: ^cibuildwheel/resources/.*py$
# Autoremoves unused imports # Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln - repo: https://github.com/hadialqattan/pycln
@@ -31,6 +32,8 @@ repos:
rev: 5.10.1 rev: 5.10.1
hooks: hooks:
- id: isort - id: isort
args: ["-a", "from __future__ import annotations"]
exclude: ^cibuildwheel/resources/.*py$
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.6.0 rev: 22.6.0
+2
View File
@@ -1,5 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import annotations
import argparse import argparse
import os import os
import subprocess import subprocess
+2
View File
@@ -1,5 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import annotations
import os import os
import shutil import shutil
import subprocess import subprocess
+2
View File
@@ -1,5 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from __future__ import annotations
import re import re
import sys import sys
from pathlib import Path from pathlib import Path
+2
View File
@@ -1 +1,3 @@
from __future__ import annotations
__version__ = "2.8.1" __version__ = "2.8.1"
+11 -10
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import argparse import argparse
import os import os
import shutil import shutil
@@ -7,7 +9,6 @@ import tempfile
import textwrap import textwrap
from pathlib import Path from pathlib import Path
from tempfile import mkdtemp from tempfile import mkdtemp
from typing import List, Set, Union
import cibuildwheel import cibuildwheel
import cibuildwheel.linux import cibuildwheel.linux
@@ -257,7 +258,7 @@ def build_in_directory(args: CommandLineArguments) -> None:
log.warning(f"Can't delete temporary folder '{str(tmp_path)}'") log.warning(f"Can't delete temporary folder '{str(tmp_path)}'")
def print_preamble(platform: str, options: Options, identifiers: List[str]) -> None: def print_preamble(platform: str, options: Options, identifiers: list[str]) -> None:
print( print(
textwrap.dedent( textwrap.dedent(
""" """
@@ -287,13 +288,13 @@ def print_preamble(platform: str, options: Options, identifiers: List[str]) -> N
def get_build_identifiers( def get_build_identifiers(
platform: PlatformName, build_selector: BuildSelector, architectures: Set[Architecture] platform: PlatformName, build_selector: BuildSelector, architectures: set[Architecture]
) -> List[str]: ) -> list[str]:
python_configurations: Union[ python_configurations: (
List[cibuildwheel.linux.PythonConfiguration], list[cibuildwheel.linux.PythonConfiguration]
List[cibuildwheel.windows.PythonConfiguration], | list[cibuildwheel.windows.PythonConfiguration]
List[cibuildwheel.macos.PythonConfiguration], | list[cibuildwheel.macos.PythonConfiguration]
] )
if platform == "linux": if platform == "linux":
python_configurations = cibuildwheel.linux.get_python_configurations( python_configurations = cibuildwheel.linux.get_python_configurations(
@@ -313,7 +314,7 @@ def get_build_identifiers(
return [config.identifier for config in python_configurations] return [config.identifier for config in python_configurations]
def detect_warnings(*, options: Options, identifiers: List[str]) -> List[str]: def detect_warnings(*, options: Options, identifiers: list[str]) -> list[str]:
warnings = [] warnings = []
# warn about deprecated {python} and {pip} # warn about deprecated {python} and {pip}
+8 -7
View File
@@ -1,8 +1,9 @@
from __future__ import annotations
import functools import functools
import platform as platform_module import platform as platform_module
import re import re
from enum import Enum from enum import Enum
from typing import Set
from .typing import Final, Literal, PlatformName, assert_never from .typing import Final, Literal, PlatformName, assert_never
@@ -32,11 +33,11 @@ class Architecture(Enum):
ARM64 = "ARM64" ARM64 = "ARM64"
# Allow this to be sorted # Allow this to be sorted
def __lt__(self, other: "Architecture") -> bool: def __lt__(self, other: Architecture) -> bool:
return self.value < other.value return self.value < other.value
@staticmethod @staticmethod
def parse_config(config: str, platform: PlatformName) -> "Set[Architecture]": def parse_config(config: str, platform: PlatformName) -> set[Architecture]:
result = set() result = set()
for arch_str in re.split(r"[\s,]+", config): for arch_str in re.split(r"[\s,]+", config):
if arch_str == "auto": if arch_str == "auto":
@@ -54,7 +55,7 @@ class Architecture(Enum):
return result return result
@staticmethod @staticmethod
def auto_archs(platform: PlatformName) -> "Set[Architecture]": def auto_archs(platform: PlatformName) -> set[Architecture]:
native_architecture = Architecture(platform_module.machine()) native_architecture = Architecture(platform_module.machine())
result = {native_architecture} result = {native_architecture}
@@ -72,7 +73,7 @@ class Architecture(Enum):
return result return result
@staticmethod @staticmethod
def all_archs(platform: PlatformName) -> "Set[Architecture]": def all_archs(platform: PlatformName) -> set[Architecture]:
all_archs_map = { all_archs_map = {
"linux": { "linux": {
Architecture.x86_64, Architecture.x86_64,
@@ -87,7 +88,7 @@ class Architecture(Enum):
return all_archs_map[platform] return all_archs_map[platform]
@staticmethod @staticmethod
def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> "Set[Architecture]": def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> set[Architecture]:
archs_32 = {Architecture.i686, Architecture.x86} archs_32 = {Architecture.i686, Architecture.x86}
auto_archs = Architecture.auto_archs(platform) auto_archs = Architecture.auto_archs(platform)
@@ -101,7 +102,7 @@ class Architecture(Enum):
def allowed_architectures_check( def allowed_architectures_check(
platform: PlatformName, platform: PlatformName,
architectures: Set[Architecture], architectures: set[Architecture],
) -> None: ) -> None:
allowed_architectures = Architecture.all_archs(platform) allowed_architectures = Architecture.all_archs(platform)
+7 -5
View File
@@ -1,6 +1,8 @@
from __future__ import annotations
import subprocess import subprocess
from dataclasses import dataclass from dataclasses import dataclass
from typing import Callable, Dict, List, Optional, Sequence from typing import Callable, Dict, List, Sequence
import bashlex import bashlex
@@ -8,19 +10,19 @@ import bashlex
EnvironmentExecutor = Callable[[List[str], Dict[str, str]], str] EnvironmentExecutor = Callable[[List[str], Dict[str, str]], str]
def local_environment_executor(command: List[str], env: Dict[str, str]) -> str: def local_environment_executor(command: list[str], env: dict[str, str]) -> str:
return subprocess.run(command, env=env, text=True, stdout=subprocess.PIPE, check=True).stdout return subprocess.run(command, env=env, text=True, stdout=subprocess.PIPE, check=True).stdout
@dataclass(frozen=True) @dataclass(frozen=True)
class NodeExecutionContext: class NodeExecutionContext:
environment: Dict[str, str] environment: dict[str, str]
input: str input: str
executor: EnvironmentExecutor executor: EnvironmentExecutor
def evaluate( def evaluate(
value: str, environment: Dict[str, str], executor: Optional[EnvironmentExecutor] = None value: str, environment: dict[str, str], executor: EnvironmentExecutor | None = None
) -> str: ) -> str:
if not value: if not value:
# empty string evaluates to empty string # empty string evaluates to empty string
@@ -101,7 +103,7 @@ def evaluate_nodes_as_compound_command(
def evaluate_nodes_as_simple_command( def evaluate_nodes_as_simple_command(
nodes: List[bashlex.ast.node], context: NodeExecutionContext nodes: list[bashlex.ast.node], context: NodeExecutionContext
) -> str: ) -> str:
command = [evaluate_node(part, context=context) for part in nodes] command = [evaluate_node(part, context=context) for part in nodes]
return context.executor(command, context.environment) return context.executor(command, context.environment)
+11 -9
View File
@@ -1,5 +1,7 @@
from __future__ import annotations
import dataclasses import dataclasses
from typing import Any, Dict, List, Mapping, Optional, Sequence from typing import Any, Mapping, Sequence
import bashlex import bashlex
@@ -12,7 +14,7 @@ class EnvironmentParseError(Exception):
pass pass
def split_env_items(env_string: str) -> List[str]: def split_env_items(env_string: str) -> list[str]:
"""Splits space-separated variable assignments into a list of individual assignments. """Splits space-separated variable assignments into a list of individual assignments.
>>> split_env_items('VAR=abc') >>> split_env_items('VAR=abc')
@@ -47,8 +49,8 @@ class EnvironmentAssignment(Protocol):
def evaluated_value( def evaluated_value(
self, self,
*, *,
environment: Dict[str, str], environment: dict[str, str],
executor: Optional[bashlex_eval.EnvironmentExecutor] = None, executor: bashlex_eval.EnvironmentExecutor | None = None,
) -> str: ) -> str:
"""Returns the value of this assignment, as evaluated in the environment""" """Returns the value of this assignment, as evaluated in the environment"""
@@ -84,8 +86,8 @@ class EnvironmentAssignmentBash:
def evaluated_value( def evaluated_value(
self, self,
environment: Dict[str, str], environment: dict[str, str],
executor: Optional[bashlex_eval.EnvironmentExecutor] = None, executor: bashlex_eval.EnvironmentExecutor | None = None,
) -> str: ) -> str:
return bashlex_eval.evaluate(self.value, environment=environment, executor=executor) return bashlex_eval.evaluate(self.value, environment=environment, executor=executor)
@@ -100,7 +102,7 @@ class EnvironmentAssignmentBash:
@dataclasses.dataclass @dataclasses.dataclass
class ParsedEnvironment: class ParsedEnvironment:
assignments: List[EnvironmentAssignment] assignments: list[EnvironmentAssignment]
def __init__(self, assignments: Sequence[EnvironmentAssignment]) -> None: def __init__(self, assignments: Sequence[EnvironmentAssignment]) -> None:
self.assignments = list(assignments) self.assignments = list(assignments)
@@ -108,8 +110,8 @@ class ParsedEnvironment:
def as_dictionary( def as_dictionary(
self, self,
prev_environment: Mapping[str, str], prev_environment: Mapping[str, str],
executor: Optional[bashlex_eval.EnvironmentExecutor] = None, executor: bashlex_eval.EnvironmentExecutor | None = None,
) -> Dict[str, str]: ) -> dict[str, str]:
environment = dict(**prev_environment) environment = dict(**prev_environment)
for assignment in self.assignments: for assignment in self.assignments:
+3 -2
View File
@@ -2,8 +2,9 @@
These are utilities for the `/bin` scripts, not for the `cibuildwheel` program. These are utilities for the `/bin` scripts, not for the `cibuildwheel` program.
""" """
from __future__ import annotations
from io import StringIO from io import StringIO
from typing import Dict, List
from .typing import Protocol from .typing import Protocol
@@ -15,7 +16,7 @@ class Printable(Protocol):
... ...
def dump_python_configurations(inp: Dict[str, Dict[str, List[Dict[str, Printable]]]]) -> str: def dump_python_configurations(inp: dict[str, dict[str, list[dict[str, Printable]]]]) -> str:
output = StringIO() output = StringIO()
for header, values in inp.items(): for header, values in inp.items():
output.write(f"[{header}]\n") output.write(f"[{header}]\n")
+8 -6
View File
@@ -1,5 +1,7 @@
from __future__ import annotations
from threading import RLock from threading import RLock
from typing import Any, Callable, Generic, Optional, Type, TypeVar, overload from typing import Any, Callable, Generic, TypeVar, overload
__all__ = ["cached_property"] __all__ = ["cached_property"]
@@ -11,11 +13,11 @@ _T = TypeVar("_T")
class cached_property(Generic[_T]): class cached_property(Generic[_T]):
def __init__(self, func: Callable[[Any], _T]): def __init__(self, func: Callable[[Any], _T]):
self.func = func self.func = func
self.attrname: Optional[str] = None self.attrname: str | None = None
self.__doc__ = func.__doc__ self.__doc__ = func.__doc__
self.lock = RLock() self.lock = RLock()
def __set_name__(self, owner: Type[Any], name: str) -> None: def __set_name__(self, owner: type[Any], name: str) -> None:
if self.attrname is None: if self.attrname is None:
self.attrname = name self.attrname = name
elif name != self.attrname: elif name != self.attrname:
@@ -25,14 +27,14 @@ class cached_property(Generic[_T]):
) )
@overload @overload
def __get__(self, instance: None, owner: Optional[Type[Any]] = ...) -> "cached_property[_T]": def __get__(self, instance: None, owner: type[Any] | None = ...) -> cached_property[_T]:
... ...
@overload @overload
def __get__(self, instance: object, owner: Optional[Type[Any]] = ...) -> _T: def __get__(self, instance: object, owner: type[Any] | None = ...) -> _T:
... ...
def __get__(self, instance: Optional[object], owner: Optional[Type[Any]] = None) -> Any: def __get__(self, instance: object | None, owner: type[Any] | None = None) -> Any:
if instance is None: if instance is None:
return self return self
if self.attrname is None: if self.attrname is None:
+11 -9
View File
@@ -1,9 +1,11 @@
from __future__ import annotations
import subprocess import subprocess
import sys import sys
import textwrap import textwrap
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path, PurePath, PurePosixPath from pathlib import Path, PurePath, PurePosixPath
from typing import Iterator, List, Set, Tuple from typing import Iterator, Tuple
from .architecture import Architecture from .architecture import Architecture
from .logger import log from .logger import log
@@ -35,15 +37,15 @@ class PythonConfiguration:
@dataclass(frozen=True) @dataclass(frozen=True)
class BuildStep: class BuildStep:
platform_configs: List[PythonConfiguration] platform_configs: list[PythonConfiguration]
platform_tag: str platform_tag: str
container_image: str container_image: str
def get_python_configurations( def get_python_configurations(
build_selector: BuildSelector, build_selector: BuildSelector,
architectures: Set[Architecture], architectures: set[Architecture],
) -> List[PythonConfiguration]: ) -> list[PythonConfiguration]:
full_python_configs = read_python_configs("linux") full_python_configs = read_python_configs("linux")
@@ -79,7 +81,7 @@ def container_image_for_python_configuration(config: PythonConfiguration, option
def get_build_steps( def get_build_steps(
options: Options, python_configurations: List[PythonConfiguration] options: Options, python_configurations: list[PythonConfiguration]
) -> Iterator[BuildStep]: ) -> Iterator[BuildStep]:
""" """
Groups PythonConfigurations into BuildSteps. Each BuildStep represents a Groups PythonConfigurations into BuildSteps. Each BuildStep represents a
@@ -110,7 +112,7 @@ def get_build_steps(
def build_in_container( def build_in_container(
*, *,
options: Options, options: Options,
platform_configs: List[PythonConfiguration], platform_configs: list[PythonConfiguration],
container: OCIContainer, container: OCIContainer,
container_project_path: PurePath, container_project_path: PurePath,
container_package_dir: PurePath, container_package_dir: PurePath,
@@ -140,13 +142,13 @@ def build_in_container(
) )
container.call(["sh", "-c", before_all_prepared], env=env) container.call(["sh", "-c", before_all_prepared], env=env)
built_wheels: List[PurePosixPath] = [] built_wheels: list[PurePosixPath] = []
for config in platform_configs: for config in platform_configs:
log.build_start(config.identifier) log.build_start(config.identifier)
build_options = options.build_options(config.identifier) build_options = options.build_options(config.identifier)
dependency_constraint_flags: List[PathOrStr] = [] dependency_constraint_flags: list[PathOrStr] = []
if build_options.dependency_constraints: if build_options.dependency_constraints:
constraints_file = build_options.dependency_constraints.get_for_python_version( constraints_file = build_options.dependency_constraints.get_for_python_version(
@@ -395,7 +397,7 @@ def build(options: Options, tmp_path: Path) -> None: # pylint: disable=unused-a
sys.exit(1) sys.exit(1)
def _matches_prepared_command(error_cmd: List[str], command_template: str) -> bool: def _matches_prepared_command(error_cmd: list[str], command_template: str) -> bool:
if len(error_cmd) < 3 or error_cmd[0:2] != ["sh", "-c"]: if len(error_cmd) < 3 or error_cmd[0:2] != ["sh", "-c"]:
return False return False
command_prefix = command_template.split("{", maxsplit=1)[0].strip() command_prefix = command_template.split("{", maxsplit=1)[0].strip()
+11 -9
View File
@@ -1,9 +1,11 @@
from __future__ import annotations
import codecs import codecs
import os import os
import re import re
import sys import sys
import time import time
from typing import IO, AnyStr, Optional, Union from typing import IO, AnyStr
from cibuildwheel.typing import Final from cibuildwheel.typing import Final
from cibuildwheel.util import CIProvider, detect_ci_provider from cibuildwheel.util import CIProvider, detect_ci_provider
@@ -39,10 +41,10 @@ class Logger:
fold_mode: str fold_mode: str
colors_enabled: bool colors_enabled: bool
unicode_enabled: bool unicode_enabled: bool
active_build_identifier: Optional[str] = None active_build_identifier: str | None = None
build_start_time: Optional[float] = None build_start_time: float | None = None
step_start_time: Optional[float] = None step_start_time: float | None = None
active_fold_group_name: Optional[str] = None active_fold_group_name: str | None = None
def __init__(self) -> None: def __init__(self) -> None:
if sys.platform == "win32" and hasattr(sys.stdout, "reconfigure"): if sys.platform == "win32" and hasattr(sys.stdout, "reconfigure"):
@@ -120,7 +122,7 @@ class Logger:
self.step_start_time = None self.step_start_time = None
def step_end_with_error(self, error: Union[BaseException, str]) -> None: def step_end_with_error(self, error: BaseException | str) -> None:
self.step_end(success=False) self.step_end(success=False)
self.error(error) self.error(error)
@@ -131,7 +133,7 @@ class Logger:
c = self.colors c = self.colors
print(f"{c.yellow}Warning{c.end}: {message}\n", file=sys.stderr) print(f"{c.yellow}Warning{c.end}: {message}\n", file=sys.stderr)
def error(self, error: Union[BaseException, str]) -> None: def error(self, error: BaseException | str) -> None:
if self.fold_mode == "github": if self.fold_mode == "github":
print(f"::error::{error}\n", file=sys.stderr) print(f"::error::{error}\n", file=sys.stderr)
else: else:
@@ -174,11 +176,11 @@ class Logger:
return identifier.lower()[:20] return identifier.lower()[:20]
@property @property
def colors(self) -> "Colors": def colors(self) -> Colors:
return Colors(enabled=self.colors_enabled) return Colors(enabled=self.colors_enabled)
@property @property
def symbols(self) -> "Symbols": def symbols(self) -> Symbols:
return Symbols(unicode=self.unicode_enabled) return Symbols(unicode=self.unicode_enabled)
+10 -8
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import functools import functools
import os import os
import platform import platform
@@ -7,7 +9,7 @@ import subprocess
import sys import sys
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import Dict, List, Sequence, Set, Tuple, cast from typing import Sequence, Tuple, cast
from filelock import FileLock from filelock import FileLock
@@ -37,7 +39,7 @@ from .util import (
) )
def get_macos_version() -> Tuple[int, int]: def get_macos_version() -> tuple[int, int]:
""" """
Returns the macOS major/minor version, as a tuple, e.g. (10, 15) or (11, 0) Returns the macOS major/minor version, as a tuple, e.g. (10, 15) or (11, 0)
@@ -51,7 +53,7 @@ def get_macos_version() -> Tuple[int, int]:
return cast(Tuple[int, int], version) return cast(Tuple[int, int], version)
def get_macos_sdks() -> List[str]: def get_macos_sdks() -> list[str]:
output = call("xcodebuild", "-showsdks", capture_stdout=True) output = call("xcodebuild", "-showsdks", capture_stdout=True)
return [m.group(1) for m in re.finditer(r"-sdk (macosx\S+)", output)] return [m.group(1) for m in re.finditer(r"-sdk (macosx\S+)", output)]
@@ -64,8 +66,8 @@ class PythonConfiguration:
def get_python_configurations( def get_python_configurations(
build_selector: BuildSelector, architectures: Set[Architecture] build_selector: BuildSelector, architectures: set[Architecture]
) -> List[PythonConfiguration]: ) -> list[PythonConfiguration]:
full_python_configs = read_python_configs("macos") full_python_configs = read_python_configs("macos")
@@ -134,7 +136,7 @@ def setup_python(
dependency_constraint_flags: Sequence[PathOrStr], dependency_constraint_flags: Sequence[PathOrStr],
environment: ParsedEnvironment, environment: ParsedEnvironment,
build_frontend: BuildFrontend, build_frontend: BuildFrontend,
) -> Dict[str, str]: ) -> dict[str, str]:
tmp.mkdir() tmp.mkdir()
implementation_id = python_configuration.identifier.split("-")[0] implementation_id = python_configuration.identifier.split("-")[0]
log.step(f"Installing Python {implementation_id}...") log.step(f"Installing Python {implementation_id}...")
@@ -295,7 +297,7 @@ def build(options: Options, tmp_path: Path) -> None:
) )
shell(before_all_prepared, env=env) shell(before_all_prepared, env=env)
built_wheels: List[Path] = [] built_wheels: list[Path] = []
for config in python_configurations: for config in python_configurations:
build_options = options.build_options(config.identifier) build_options = options.build_options(config.identifier)
@@ -418,7 +420,7 @@ def build(options: Options, tmp_path: Path) -> None:
if build_options.test_command and build_options.test_selector(config.identifier): if build_options.test_command and build_options.test_selector(config.identifier):
machine_arch = platform.machine() machine_arch = platform.machine()
testing_archs: List[Literal["x86_64", "arm64"]] testing_archs: list[Literal["x86_64", "arm64"]]
if config_is_arm64: if config_is_arm64:
testing_archs = ["arm64"] testing_archs = ["arm64"]
+14 -12
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import io import io
import json import json
import os import os
@@ -9,7 +11,7 @@ import sys
import uuid import uuid
from pathlib import Path, PurePath, PurePosixPath from pathlib import Path, PurePath, PurePosixPath
from types import TracebackType from types import TracebackType
from typing import IO, Dict, List, Optional, Sequence, Type, cast from typing import IO, Dict, Sequence, cast
from cibuildwheel.util import CIProvider, detect_ci_provider from cibuildwheel.util import CIProvider, detect_ci_provider
@@ -52,7 +54,7 @@ class OCIContainer:
*, *,
image: str, image: str,
simulate_32_bit: bool = False, simulate_32_bit: bool = False,
cwd: Optional[PathOrStr] = None, cwd: PathOrStr | None = None,
engine: ContainerEngine = "docker", engine: ContainerEngine = "docker",
): ):
if not image: if not image:
@@ -61,10 +63,10 @@ class OCIContainer:
self.image = image self.image = image
self.simulate_32_bit = simulate_32_bit self.simulate_32_bit = simulate_32_bit
self.cwd = cwd self.cwd = cwd
self.name: Optional[str] = None self.name: str | None = None
self.engine = engine self.engine = engine
def __enter__(self) -> "OCIContainer": def __enter__(self) -> OCIContainer:
self.name = f"cibuildwheel-{uuid.uuid4()}" self.name = f"cibuildwheel-{uuid.uuid4()}"
@@ -122,9 +124,9 @@ class OCIContainer:
def __exit__( def __exit__(
self, self,
exc_type: Optional[Type[BaseException]], exc_type: type[BaseException] | None,
exc_val: Optional[BaseException], exc_val: BaseException | None,
exc_tb: Optional[TracebackType], exc_tb: TracebackType | None,
) -> None: ) -> None:
self.bash_stdin.write(b"exit 0\n") self.bash_stdin.write(b"exit 0\n")
@@ -217,7 +219,7 @@ class OCIContainer:
else: else:
raise KeyError(self.engine) raise KeyError(self.engine)
def glob(self, path: PurePosixPath, pattern: str) -> List[PurePosixPath]: def glob(self, path: PurePosixPath, pattern: str) -> list[PurePosixPath]:
glob_pattern = path.joinpath(pattern) glob_pattern = path.joinpath(pattern)
path_strings = json.loads( path_strings = json.loads(
@@ -236,9 +238,9 @@ class OCIContainer:
def call( def call(
self, self,
args: Sequence[PathOrStr], args: Sequence[PathOrStr],
env: Optional[Dict[str, str]] = None, env: dict[str, str] | None = None,
capture_output: bool = False, capture_output: bool = False,
cwd: Optional[PathOrStr] = None, cwd: PathOrStr | None = None,
) -> str: ) -> str:
if cwd is None: if cwd is None:
@@ -314,7 +316,7 @@ class OCIContainer:
return output return output
def get_environment(self) -> Dict[str, str]: def get_environment(self) -> dict[str, str]:
env = json.loads( env = json.loads(
self.call( self.call(
[ [
@@ -327,7 +329,7 @@ class OCIContainer:
) )
return cast(Dict[str, str], env) return cast(Dict[str, str], env)
def environment_executor(self, command: List[str], environment: Dict[str, str]) -> str: def environment_executor(self, command: list[str], environment: dict[str, str]) -> str:
# used as an EnvironmentExecutor to evaluate commands and capture output # used as an EnvironmentExecutor to evaluate commands and capture output
return self.call(command, env=environment, capture_output=True) return self.call(command, env=environment, capture_output=True)
+36 -45
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import functools import functools
import os import os
import sys import sys
@@ -6,18 +8,7 @@ from configparser import ConfigParser
from contextlib import contextmanager from contextlib import contextmanager
from dataclasses import asdict, dataclass from dataclasses import asdict, dataclass
from pathlib import Path from pathlib import Path
from typing import ( from typing import Any, Dict, Generator, List, Mapping, Union, cast
Any,
Dict,
Generator,
List,
Mapping,
Optional,
Set,
Tuple,
Union,
cast,
)
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
import tomllib import tomllib
@@ -50,7 +41,7 @@ from .util import (
@dataclass @dataclass
class CommandLineArguments: class CommandLineArguments:
platform: Literal["auto", "linux", "macos", "windows"] platform: Literal["auto", "linux", "macos", "windows"]
archs: Optional[str] archs: str | None
output_dir: Path output_dir: Path
config_file: str config_file: str
package_dir: Path package_dir: Path
@@ -65,7 +56,7 @@ class GlobalOptions:
output_dir: Path output_dir: Path
build_selector: BuildSelector build_selector: BuildSelector
test_selector: TestSelector test_selector: TestSelector
architectures: Set[Architecture] architectures: set[Architecture]
container_engine: ContainerEngine container_engine: ContainerEngine
@@ -74,14 +65,14 @@ class BuildOptions:
globals: GlobalOptions globals: GlobalOptions
environment: ParsedEnvironment environment: ParsedEnvironment
before_all: str before_all: str
before_build: Optional[str] before_build: str | None
repair_command: str repair_command: str
manylinux_images: Optional[Dict[str, str]] manylinux_images: dict[str, str] | None
musllinux_images: Optional[Dict[str, str]] musllinux_images: dict[str, str] | None
dependency_constraints: Optional[DependencyConstraints] dependency_constraints: DependencyConstraints | None
test_command: Optional[str] test_command: str | None
before_test: Optional[str] before_test: str | None
test_requires: List[str] test_requires: list[str]
test_extras: str test_extras: str
build_verbosity: int build_verbosity: int
build_frontend: BuildFrontend build_frontend: BuildFrontend
@@ -103,7 +94,7 @@ class BuildOptions:
return self.globals.test_selector return self.globals.test_selector
@property @property
def architectures(self) -> Set[Architecture]: def architectures(self) -> set[Architecture]:
return self.globals.architectures return self.globals.architectures
@@ -113,7 +104,7 @@ Setting = Union[Dict[str, str], List[str], str, int]
@dataclass(frozen=True) @dataclass(frozen=True)
class Override: class Override:
select_pattern: str select_pattern: str
options: Dict[str, Setting] options: dict[str, Setting]
MANYLINUX_OPTIONS = {f"manylinux-{build_platform}-image" for build_platform in MANYLINUX_ARCHS} MANYLINUX_OPTIONS = {f"manylinux-{build_platform}-image" for build_platform in MANYLINUX_ARCHS}
@@ -134,7 +125,7 @@ class ConfigOptionError(KeyError):
pass pass
def _dig_first(*pairs: Tuple[Mapping[str, Setting], str], ignore_empty: bool = False) -> Setting: def _dig_first(*pairs: tuple[Mapping[str, Setting], str], ignore_empty: bool = False) -> Setting:
""" """
Return the first dict item that matches from pairs of dicts and keys. Return the first dict item that matches from pairs of dicts and keys.
Will throw a KeyError if missing. Will throw a KeyError if missing.
@@ -176,10 +167,10 @@ class OptionsReader:
def __init__( def __init__(
self, self,
config_file_path: Optional[Path] = None, config_file_path: Path | None = None,
*, *,
platform: PlatformName, platform: PlatformName,
disallow: Optional[Dict[str, Set[str]]] = None, disallow: dict[str, set[str]] | None = None,
) -> None: ) -> None:
self.platform = platform self.platform = platform
self.disallow = disallow or {} self.disallow = disallow or {}
@@ -189,8 +180,8 @@ class OptionsReader:
self.default_options, self.default_platform_options = self._load_file(defaults_path) self.default_options, self.default_platform_options = self._load_file(defaults_path)
# Load the project config file # Load the project config file
config_options: Dict[str, Any] = {} config_options: dict[str, Any] = {}
config_platform_options: Dict[str, Any] = {} config_platform_options: dict[str, Any] = {}
if config_file_path is not None: if config_file_path is not None:
config_options, config_platform_options = self._load_file(config_file_path) config_options, config_platform_options = self._load_file(config_file_path)
@@ -209,8 +200,8 @@ class OptionsReader:
self.config_options = config_options self.config_options = config_options
self.config_platform_options = config_platform_options self.config_platform_options = config_platform_options
self.overrides: List[Override] = [] self.overrides: list[Override] = []
self.current_identifier: Optional[str] = None self.current_identifier: str | None = None
config_overrides = self.config_options.get("overrides") config_overrides = self.config_options.get("overrides")
@@ -251,7 +242,7 @@ class OptionsReader:
return name in allowed_option_names return name in allowed_option_names
def _load_file(self, filename: Path) -> Tuple[Dict[str, Any], Dict[str, Any]]: def _load_file(self, filename: Path) -> tuple[dict[str, Any], dict[str, Any]]:
""" """
Load a toml file, returns global and platform as separate dicts. Load a toml file, returns global and platform as separate dicts.
""" """
@@ -264,7 +255,7 @@ class OptionsReader:
return global_options, platform_options return global_options, platform_options
@property @property
def active_config_overrides(self) -> List[Override]: def active_config_overrides(self) -> list[Override]:
if self.current_identifier is None: if self.current_identifier is None:
return [] return []
return [ return [
@@ -272,7 +263,7 @@ class OptionsReader:
] ]
@contextmanager @contextmanager
def identifier(self, identifier: Optional[str]) -> Generator[None, None, None]: def identifier(self, identifier: str | None) -> Generator[None, None, None]:
self.current_identifier = identifier self.current_identifier = identifier
try: try:
yield yield
@@ -284,8 +275,8 @@ class OptionsReader:
name: str, name: str,
*, *,
env_plat: bool = True, env_plat: bool = True,
sep: Optional[str] = None, sep: str | None = None,
table: Optional[TableFmt] = None, table: TableFmt | None = None,
ignore_empty: bool = False, ignore_empty: bool = False,
) -> str: ) -> str:
""" """
@@ -349,7 +340,7 @@ class Options:
) )
@property @property
def config_file_path(self) -> Optional[Path]: def config_file_path(self) -> Path | None:
args = self.command_line_arguments args = self.command_line_arguments
if args.config_file: if args.config_file:
@@ -363,7 +354,7 @@ class Options:
return None return None
@cached_property @cached_property
def package_requires_python_str(self) -> Optional[str]: def package_requires_python_str(self) -> str | None:
args = self.command_line_arguments args = self.command_line_arguments
return get_requires_python_str(Path(args.package_dir)) return get_requires_python_str(Path(args.package_dir))
@@ -383,7 +374,7 @@ class Options:
# This is not supported in tool.cibuildwheel, as it comes from a standard location. # This is not supported in tool.cibuildwheel, as it comes from a standard location.
# Passing this in as an environment variable will override pyproject.toml, setup.cfg, or setup.py # Passing this in as an environment variable will override pyproject.toml, setup.cfg, or setup.py
requires_python_str: Optional[str] = ( requires_python_str: str | None = (
os.environ.get("CIBW_PROJECT_REQUIRES_PYTHON") or self.package_requires_python_str os.environ.get("CIBW_PROJECT_REQUIRES_PYTHON") or self.package_requires_python_str
) )
requires_python = None if requires_python_str is None else SpecifierSet(requires_python_str) requires_python = None if requires_python_str is None else SpecifierSet(requires_python_str)
@@ -417,7 +408,7 @@ class Options:
container_engine=container_engine, container_engine=container_engine,
) )
def build_options(self, identifier: Optional[str]) -> BuildOptions: def build_options(self, identifier: str | None) -> BuildOptions:
""" """
Compute BuildOptions for a single run configuration. Compute BuildOptions for a single run configuration.
""" """
@@ -469,9 +460,9 @@ class Options:
pass pass
if dependency_versions == "pinned": if dependency_versions == "pinned":
dependency_constraints: Optional[ dependency_constraints: None | (
DependencyConstraints DependencyConstraints
] = DependencyConstraints.with_defaults() ) = DependencyConstraints.with_defaults()
elif dependency_versions == "latest": elif dependency_versions == "latest":
dependency_constraints = None dependency_constraints = None
else: else:
@@ -486,8 +477,8 @@ class Options:
except ValueError: except ValueError:
build_verbosity = 0 build_verbosity = 0
manylinux_images: Dict[str, str] = {} manylinux_images: dict[str, str] = {}
musllinux_images: Dict[str, str] = {} musllinux_images: dict[str, str] = {}
if self.platform == "linux": if self.platform == "linux":
all_pinned_container_images = _get_pinned_container_images() all_pinned_container_images = _get_pinned_container_images()
@@ -539,7 +530,7 @@ class Options:
build_frontend=build_frontend, build_frontend=build_frontend,
) )
def check_for_invalid_configuration(self, identifiers: List[str]) -> None: def check_for_invalid_configuration(self, identifiers: list[str]) -> None:
if self.platform in ["macos", "windows"]: if self.platform in ["macos", "windows"]:
before_all_values = {self.build_options(i).before_all for i in identifiers} before_all_values = {self.build_options(i).before_all for i in identifiers}
@@ -562,7 +553,7 @@ class Options:
deprecated_selectors("CIBW_SKIP", build_selector.skip_config) deprecated_selectors("CIBW_SKIP", build_selector.skip_config)
deprecated_selectors("CIBW_TEST_SKIP", test_selector.skip_config) deprecated_selectors("CIBW_TEST_SKIP", test_selector.skip_config)
def summary(self, identifiers: List[str]) -> str: def summary(self, identifiers: list[str]) -> str:
lines = [ lines = [
f"{option_name}: {option_value!r}" f"{option_name}: {option_value!r}"
for option_name, option_value in sorted(asdict(self.globals).items()) for option_name, option_value in sorted(asdict(self.globals).items())
+6 -4
View File
@@ -1,8 +1,10 @@
from __future__ import annotations
import ast import ast
import sys import sys
from configparser import ConfigParser from configparser import ConfigParser
from pathlib import Path from pathlib import Path
from typing import Any, Optional from typing import Any
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
import tomllib import tomllib
@@ -24,7 +26,7 @@ else:
class Analyzer(ast.NodeVisitor): class Analyzer(ast.NodeVisitor):
def __init__(self) -> None: def __init__(self) -> None:
self.requires_python: Optional[str] = None self.requires_python: str | None = None
def visit(self, node: ast.AST) -> None: def visit(self, node: ast.AST) -> None:
for inner_node in ast.walk(node): for inner_node in ast.walk(node):
@@ -43,7 +45,7 @@ class Analyzer(ast.NodeVisitor):
self.requires_python = get_constant(node.value) self.requires_python = get_constant(node.value)
def setup_py_python_requires(content: str) -> Optional[str]: def setup_py_python_requires(content: str) -> str | None:
try: try:
tree = ast.parse(content) tree = ast.parse(content)
analyzer = Analyzer() analyzer = Analyzer()
@@ -53,7 +55,7 @@ def setup_py_python_requires(content: str) -> Optional[str]:
return None return None
def get_requires_python_str(package_dir: Path) -> Optional[str]: def get_requires_python_str(package_dir: Path) -> str | None:
"""Return the python requires string from the most canonical source available, or None""" """Return the python requires string from the most canonical source available, or None"""
# Read in from pyproject.toml:project.requires-python # Read in from pyproject.toml:project.requires-python
+3 -1
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import subprocess import subprocess
import sys import sys
@@ -36,7 +38,7 @@ else:
PlatformName = Literal["linux", "macos", "windows"] PlatformName = Literal["linux", "macos", "windows"]
PLATFORMS: Final[Set[PlatformName]] = {"linux", "macos", "windows"} PLATFORMS: Final[set[PlatformName]] = {"linux", "macos", "windows"}
def assert_never(value: NoReturn) -> NoReturn: def assert_never(value: NoReturn) -> NoReturn:
+22 -26
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import contextlib import contextlib
import fnmatch import fnmatch
import itertools import itertools
@@ -18,15 +20,11 @@ from time import sleep
from typing import ( from typing import (
Any, Any,
ClassVar, ClassVar,
Dict,
Generator, Generator,
Iterable, Iterable,
List,
Optional,
Sequence, Sequence,
TextIO, TextIO,
TypeVar, TypeVar,
Union,
cast, cast,
overload, overload,
) )
@@ -98,8 +96,8 @@ IS_WIN: Final = sys.platform.startswith("win")
@overload @overload
def call( def call(
*args: PathOrStr, *args: PathOrStr,
env: Optional[Dict[str, str]] = None, env: dict[str, str] | None = None,
cwd: Optional[PathOrStr] = None, cwd: PathOrStr | None = None,
capture_stdout: Literal[False] = ..., capture_stdout: Literal[False] = ...,
) -> None: ) -> None:
... ...
@@ -108,8 +106,8 @@ def call(
@overload @overload
def call( def call(
*args: PathOrStr, *args: PathOrStr,
env: Optional[Dict[str, str]] = None, env: dict[str, str] | None = None,
cwd: Optional[PathOrStr] = None, cwd: PathOrStr | None = None,
capture_stdout: Literal[True], capture_stdout: Literal[True],
) -> str: ) -> str:
... ...
@@ -117,10 +115,10 @@ def call(
def call( def call(
*args: PathOrStr, *args: PathOrStr,
env: Optional[Dict[str, str]] = None, env: dict[str, str] | None = None,
cwd: Optional[PathOrStr] = None, cwd: PathOrStr | None = None,
capture_stdout: bool = False, capture_stdout: bool = False,
) -> Optional[str]: ) -> str | None:
""" """
Run subprocess.run, but print the commands first. Takes the commands as Run subprocess.run, but print the commands first. Takes the commands as
*args. Uses shell=True on Windows due to a bug. Also converts to *args. Uses shell=True on Windows due to a bug. Also converts to
@@ -130,7 +128,7 @@ def call(
args_ = [str(arg) for arg in args] args_ = [str(arg) for arg in args]
# print the command executing for the logs # print the command executing for the logs
print("+ " + " ".join(shlex.quote(a) for a in args_)) print("+ " + " ".join(shlex.quote(a) for a in args_))
kwargs: Dict[str, Any] = {} kwargs: dict[str, Any] = {}
if capture_stdout: if capture_stdout:
kwargs["universal_newlines"] = True kwargs["universal_newlines"] = True
kwargs["stdout"] = subprocess.PIPE kwargs["stdout"] = subprocess.PIPE
@@ -140,9 +138,7 @@ def call(
return cast(str, result.stdout) return cast(str, result.stdout)
def shell( def shell(*commands: str, env: dict[str, str] | None = None, cwd: PathOrStr | None = None) -> None:
*commands: str, env: Optional[Dict[str, str]] = None, cwd: Optional[PathOrStr] = None
) -> None:
command = " ".join(commands) command = " ".join(commands)
print(f"+ {command}") print(f"+ {command}")
subprocess.run(command, env=env, cwd=cwd, shell=True, check=True) subprocess.run(command, env=env, cwd=cwd, shell=True, check=True)
@@ -200,7 +196,7 @@ def prepare_command(command: str, **kwargs: PathOrStr) -> str:
return format_safe(command, python="python", pip="pip", **kwargs) return format_safe(command, python="python", pip="pip", **kwargs)
def get_build_verbosity_extra_flags(level: int) -> List[str]: def get_build_verbosity_extra_flags(level: int) -> list[str]:
if level > 0: if level > 0:
return ["-" + level * "v"] return ["-" + level * "v"]
elif level < 0: elif level < 0:
@@ -209,11 +205,11 @@ def get_build_verbosity_extra_flags(level: int) -> List[str]:
return [] return []
def read_python_configs(config: PlatformName) -> List[Dict[str, str]]: def read_python_configs(config: PlatformName) -> list[dict[str, str]]:
input_file = resources_dir / "build-platforms.toml" input_file = resources_dir / "build-platforms.toml"
with input_file.open("rb") as f: with input_file.open("rb") as f:
loaded_file = tomllib.load(f) loaded_file = tomllib.load(f)
results: List[Dict[str, str]] = list(loaded_file[config]["python_configurations"]) results: list[dict[str, str]] = list(loaded_file[config]["python_configurations"])
return results return results
@@ -243,7 +239,7 @@ class BuildSelector:
build_config: str build_config: str
skip_config: str skip_config: str
requires_python: Optional[SpecifierSet] = None requires_python: SpecifierSet | None = None
# a pattern that skips prerelease versions, when include_prereleases is False. # a pattern that skips prerelease versions, when include_prereleases is False.
PRERELEASE_SKIP: ClassVar[str] = "cp311-*" PRERELEASE_SKIP: ClassVar[str] = "cp311-*"
@@ -328,7 +324,7 @@ class DependencyConstraints:
self.base_file_path = base_file_path.resolve() self.base_file_path = base_file_path.resolve()
@staticmethod @staticmethod
def with_defaults() -> "DependencyConstraints": def with_defaults() -> DependencyConstraints:
return DependencyConstraints(base_file_path=resources_dir / "constraints.txt") return DependencyConstraints(base_file_path=resources_dir / "constraints.txt")
def get_for_python_version(self, version: str) -> Path: def get_for_python_version(self, version: str) -> Path:
@@ -400,7 +396,7 @@ class CIProvider(Enum):
other = "other" other = "other"
def detect_ci_provider() -> Optional[CIProvider]: def detect_ci_provider() -> CIProvider | None:
if "TRAVIS" in os.environ: if "TRAVIS" in os.environ:
return CIProvider.travis_ci return CIProvider.travis_ci
elif "APPVEYOR" in os.environ: elif "APPVEYOR" in os.environ:
@@ -473,7 +469,7 @@ def print_new_wheels(msg: str, output_dir: Path) -> Generator[None, None, None]:
) )
def get_pip_version(env: Dict[str, str]) -> str: def get_pip_version(env: dict[str, str]) -> str:
versions_output_text = call( versions_output_text = call(
"python", "-m", "pip", "freeze", "--all", capture_stdout=True, env=env "python", "-m", "pip", "freeze", "--all", capture_stdout=True, env=env
) )
@@ -501,7 +497,7 @@ def _ensure_virtualenv() -> Path:
def _parse_constraints_for_virtualenv( def _parse_constraints_for_virtualenv(
dependency_constraint_flags: Sequence[PathOrStr], dependency_constraint_flags: Sequence[PathOrStr],
) -> Dict[str, str]: ) -> dict[str, str]:
""" """
Parses the constraints file referenced by `dependency_constraint_flags` and returns a dict where Parses the constraints file referenced by `dependency_constraint_flags` and returns a dict where
the key is the package name, and the value is the constraint version. the key is the package name, and the value is the constraint version.
@@ -547,7 +543,7 @@ def _parse_constraints_for_virtualenv(
def virtualenv( def virtualenv(
python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr] python: Path, venv_path: Path, dependency_constraint_flags: Sequence[PathOrStr]
) -> Dict[str, str]: ) -> dict[str, str]:
assert python.exists() assert python.exists()
virtualenv_app = _ensure_virtualenv() virtualenv_app = _ensure_virtualenv()
constraints = _parse_constraints_for_virtualenv(dependency_constraint_flags) constraints = _parse_constraints_for_virtualenv(dependency_constraint_flags)
@@ -589,7 +585,7 @@ def virtualenv(
T = TypeVar("T", bound=PurePath) T = TypeVar("T", bound=PurePath)
def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]: def find_compatible_wheel(wheels: Sequence[T], identifier: str) -> T | None:
""" """
Finds a wheel with an abi3 or a none ABI tag in `wheels` compatible with the Python interpreter Finds a wheel with an abi3 or a none ABI tag in `wheels` compatible with the Python interpreter
specified by `identifier` that is previously built. specified by `identifier` that is previously built.
@@ -641,7 +637,7 @@ else:
# Can be replaced by contextlib.chdir in Python 3.11 # Can be replaced by contextlib.chdir in Python 3.11
@contextlib.contextmanager @contextlib.contextmanager
def chdir(new_path: Union[Path, str]) -> Generator[None, None, None]: def chdir(new_path: Path | str) -> Generator[None, None, None]:
"""Non thread-safe context manager to change the current working directory.""" """Non thread-safe context manager to change the current working directory."""
cwd = os.getcwd() cwd = os.getcwd()
+9 -7
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import shutil import shutil
import subprocess import subprocess
@@ -5,7 +7,7 @@ import sys
from dataclasses import dataclass from dataclasses import dataclass
from functools import lru_cache from functools import lru_cache
from pathlib import Path from pathlib import Path
from typing import Dict, List, Optional, Sequence, Set from typing import Sequence
from zipfile import ZipFile from zipfile import ZipFile
from filelock import FileLock from filelock import FileLock
@@ -34,7 +36,7 @@ from .util import (
) )
def get_nuget_args(version: str, arch: str, output_directory: Path) -> List[str]: def get_nuget_args(version: str, arch: str, output_directory: Path) -> list[str]:
platform_suffix = {"32": "x86", "64": "", "ARM64": "arm64"} platform_suffix = {"32": "x86", "64": "", "ARM64": "arm64"}
python_name = "python" + platform_suffix[arch] python_name = "python" + platform_suffix[arch]
return [ return [
@@ -53,13 +55,13 @@ class PythonConfiguration:
version: str version: str
arch: str arch: str
identifier: str identifier: str
url: Optional[str] = None url: str | None = None
def get_python_configurations( def get_python_configurations(
build_selector: BuildSelector, build_selector: BuildSelector,
architectures: Set[Architecture], architectures: set[Architecture],
) -> List[PythonConfiguration]: ) -> list[PythonConfiguration]:
full_python_configs = read_python_configs("windows") full_python_configs = read_python_configs("windows")
@@ -124,7 +126,7 @@ def setup_python(
dependency_constraint_flags: Sequence[PathOrStr], dependency_constraint_flags: Sequence[PathOrStr],
environment: ParsedEnvironment, environment: ParsedEnvironment,
build_frontend: BuildFrontend, build_frontend: BuildFrontend,
) -> Dict[str, str]: ) -> dict[str, str]:
tmp.mkdir() tmp.mkdir()
implementation_id = python_configuration.identifier.split("-")[0] implementation_id = python_configuration.identifier.split("-")[0]
log.step(f"Installing Python {implementation_id}...") log.step(f"Installing Python {implementation_id}...")
@@ -253,7 +255,7 @@ def build(options: Options, tmp_path: Path) -> None:
) )
shell(before_all_prepared, env=env) shell(before_all_prepared, env=env)
built_wheels: List[Path] = [] built_wheels: list[Path] = []
for config in python_configurations: for config in python_configurations:
build_options = options.build_options(config.identifier) build_options = options.build_options(config.identifier)
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
from typing import Any from typing import Any
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import shutil import shutil
import sys import sys
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from setuptools import setup from setuptools import setup
extras = { extras = {
+2 -2
View File
@@ -1,4 +1,4 @@
from typing import Dict from __future__ import annotations
import pytest import pytest
@@ -13,5 +13,5 @@ def pytest_addoption(parser) -> None:
@pytest.fixture( @pytest.fixture(
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"] params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
) )
def build_frontend_env(request) -> Dict[str, str]: def build_frontend_env(request) -> dict[str, str]:
return request.param # type: ignore[no-any-return] return request.param # type: ignore[no-any-return]
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap import textwrap
import pytest import pytest
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap import textwrap
from . import test_projects, utils from . import test_projects, utils
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from . import test_projects, utils from . import test_projects, utils
before_test_project = test_projects.new_c_project() before_test_project = test_projects.new_c_project()
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap import textwrap
from . import test_projects, utils from . import test_projects, utils
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import platform import platform
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import jinja2 import jinja2
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import re import re
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
import pytest import pytest
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import subprocess import subprocess
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import subprocess import subprocess
import sys import sys
+3 -2
View File
@@ -1,6 +1,7 @@
from __future__ import annotations
import platform import platform
import subprocess import subprocess
from typing import Tuple
import pytest import pytest
@@ -14,7 +15,7 @@ ALL_MACOS_WHEELS = {
} }
def get_xcode_version() -> Tuple[int, int]: def get_xcode_version() -> tuple[int, int]:
output = subprocess.run( output = subprocess.run(
["xcodebuild", "-version"], ["xcodebuild", "-version"],
text=True, text=True,
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import platform import platform
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap import textwrap
from . import test_projects, utils from . import test_projects, utils
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import pytest import pytest
from . import test_projects, utils from . import test_projects, utils
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from .base import TestProject from .base import TestProject
from .c import new_c_project from .c import new_c_project
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import importlib import importlib
import subprocess import subprocess
import sys import sys
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import Any, Dict, Union from typing import Any, Dict, Union
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import jinja2 import jinja2
from .base import TestProject from .base import TestProject
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
from test import test_projects from test import test_projects
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
from test import test_projects from test import test_projects
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap import textwrap
from . import test_projects, utils from . import test_projects, utils
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
import jinja2 import jinja2
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import subprocess import subprocess
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import subprocess import subprocess
import pytest import pytest
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import pytest import pytest
from . import test_projects, utils from . import test_projects, utils
+2
View File
@@ -4,6 +4,8 @@ Utility functions used by the cibuildwheel tests.
This file is added to the PYTHONPATH in the test runner at bin/run_test.py. This file is added to the PYTHONPATH in the test runner at bin/run_test.py.
""" """
from __future__ import annotations
import os import os
import platform as pm import platform as pm
import subprocess import subprocess
+3 -2
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import sys import sys
from typing import Dict, List
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
import tomllib import tomllib
@@ -27,7 +28,7 @@ def test_compare_configs():
def test_dump_with_Version(): def test_dump_with_Version():
# MyPy doesn't understand deeply nested dicts correctly # MyPy doesn't understand deeply nested dicts correctly
example: Dict[str, Dict[str, List[Dict[str, Printable]]]] = { example: dict[str, dict[str, list[dict[str, Printable]]]] = {
"windows": { "windows": {
"python_configurations": [ "python_configurations": [
{"identifier": "cp27-win32", "version": Version("2.7.18"), "arch": "32"}, {"identifier": "cp27-win32", "version": Version("2.7.18"), "arch": "32"},
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from packaging.specifiers import SpecifierSet from packaging.specifiers import SpecifierSet
from cibuildwheel.util import BuildSelector from cibuildwheel.util import BuildSelector
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import sys import sys
from pathlib import Path from pathlib import Path
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
from cibuildwheel.util import DependencyConstraints from cibuildwheel.util import DependencyConstraints
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import ssl import ssl
import certifi import certifi
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
from cibuildwheel.environment import parse_environment from cibuildwheel.environment import parse_environment
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import textwrap import textwrap
from pathlib import Path from pathlib import Path
from pprint import pprint from pprint import pprint
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import contextlib import contextlib
import platform as platform_module import platform as platform_module
import subprocess import subprocess
@@ -1,3 +1,5 @@
from __future__ import annotations
import sys import sys
from fnmatch import fnmatch from fnmatch import fnmatch
from pathlib import Path from pathlib import Path
@@ -1,3 +1,5 @@
from __future__ import annotations
import sys import sys
import pytest import pytest
@@ -1,3 +1,5 @@
from __future__ import annotations
import sys import sys
import textwrap import textwrap
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import os import os
import platform import platform
import random import random
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import platform as platform_module import platform as platform_module
import subprocess import subprocess
import sys import sys
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import platform as platform_module import platform as platform_module
import pytest import pytest
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
import pytest import pytest
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from textwrap import dedent from textwrap import dedent
from cibuildwheel.projectfiles import get_requires_python_str, setup_py_python_requires from cibuildwheel.projectfiles import get_requires_python_str, setup_py_python_requires
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import Path from pathlib import Path
from cibuildwheel.options import CommandLineArguments from cibuildwheel.options import CommandLineArguments
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
from pathlib import PurePath from pathlib import PurePath
import pytest import pytest
+2
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
import pytest import pytest
from cibuildwheel.util import print_new_wheels from cibuildwheel.util import print_new_wheels