Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

__lazy_modules__ = [
"argparse",
"cibuildwheel.architecture",
Expand All @@ -12,7 +14,6 @@
"cibuildwheel.util.helpers",
"cibuildwheel.util.resources",
"collections",
"collections.abc",
"contextlib",
"functools",
"os",
Expand All @@ -37,10 +38,8 @@
import textwrap
import traceback
import typing
from collections.abc import Generator, Iterable, Sequence
from pathlib import Path
from tempfile import mkdtemp
from typing import Any, Literal, TextIO

import cibuildwheel
import cibuildwheel.util
Expand All @@ -56,6 +55,11 @@
from cibuildwheel.util.helpers import strtobool
from cibuildwheel.util.resources import read_all_configs

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Generator, Iterable, Sequence
from typing import Any, Literal, TextIO


@dataclasses.dataclass
class GlobalOptions:
Expand Down
25 changes: 15 additions & 10 deletions cibuildwheel/architecture.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

__lazy_modules__ = [
"cibuildwheel.typing",
"collections",
"collections.abc",
"platform",
"re",
"shutil",
Expand All @@ -15,12 +15,17 @@
import subprocess
import sys
import typing
from collections.abc import Set
from enum import StrEnum, auto
from typing import Final, Literal
from typing import Final

from cibuildwheel import errors
from cibuildwheel.typing import PlatformName

TYPE_CHECKING = False
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
if TYPE_CHECKING:
from collections.abc import Set
from typing import Literal

from cibuildwheel.typing import PlatformName

PRETTY_NAMES: Final[dict[PlatformName, str]] = {
"linux": "Linux",
Expand Down Expand Up @@ -94,7 +99,7 @@ class Architecture(StrEnum):
x86_64_iphonesimulator = auto()

@staticmethod
def parse_config(config: str, platform: PlatformName) -> "set[Architecture]":
def parse_config(config: str, platform: PlatformName) -> set[Architecture]:
result = set()
for arch_str in re.split(r"[\s,]+", config):
match arch_str:
Expand All @@ -118,7 +123,7 @@ def parse_config(config: str, platform: PlatformName) -> "set[Architecture]":
return result

@staticmethod
def native_arch(platform: PlatformName) -> "Architecture | None":
def native_arch(platform: PlatformName) -> Architecture | None:
native_machine = platform_module.machine()
native_architecture = Architecture(native_machine)

Expand Down Expand Up @@ -155,7 +160,7 @@ def native_arch(platform: PlatformName) -> "Architecture | None":
return native_architecture

@staticmethod
def auto_archs(platform: PlatformName) -> "set[Architecture]":
def auto_archs(platform: PlatformName) -> set[Architecture]:
native_arch = Architecture.native_arch(platform)
if native_arch is None:
return set() # can't build anything on this platform
Expand All @@ -171,7 +176,7 @@ def auto_archs(platform: PlatformName) -> "set[Architecture]":
return result

@staticmethod
def all_archs(platform: PlatformName) -> "set[Architecture]":
def all_archs(platform: PlatformName) -> set[Architecture]:
all_archs_map = {
"linux": {
Architecture.x86_64,
Expand All @@ -195,7 +200,7 @@ def all_archs(platform: PlatformName) -> "set[Architecture]":
return all_archs_map[platform]

@staticmethod
def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> "set[Architecture]":
def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> set[Architecture]:
# This map maps 64-bit architectures to their 32-bit equivalents.
archs_map = {
Architecture.x86_64: Architecture.i686,
Expand Down
12 changes: 9 additions & 3 deletions cibuildwheel/environment.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
__lazy_modules__ = ["bashlex", "bashlex.errors", "collections", "collections.abc"]
from __future__ import annotations

__lazy_modules__ = ["bashlex", "bashlex.errors", "collections"]

import dataclasses
from collections.abc import Mapping, Sequence
from typing import Any, Protocol
from typing import Protocol

import bashlex
import bashlex.errors

from cibuildwheel import bashlex_eval

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Mapping, Sequence
from typing import Any


class EnvironmentParseError(Exception):
pass
Expand Down
11 changes: 8 additions & 3 deletions cibuildwheel/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
These are utilities for the `/bin` scripts, not for the `cibuildwheel` program.
"""

from __future__ import annotations

__lazy_modules__ = [
"collections",
"collections.abc",
"io",
"json",
"time",
Expand All @@ -18,14 +19,18 @@
import typing
import urllib.error
import urllib.request
from collections.abc import Mapping, Sequence
from io import StringIO
from typing import Any, NotRequired, Protocol
from typing import NotRequired, Protocol

from cibuildwheel import __version__ as cibw_version

__all__ = ("Printable", "dump_python_configurations")

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Mapping, Sequence
from typing import Any


class Printable(Protocol):
def __str__(self) -> str: ...
Expand Down
8 changes: 6 additions & 2 deletions cibuildwheel/frontend.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from __future__ import annotations

__lazy_modules__ = [
"cibuildwheel.logger",
"cibuildwheel.util.helpers",
"collections",
"collections.abc",
"shlex",
]

import dataclasses
import shlex
import typing
from collections.abc import Sequence
from typing import Literal, Self, get_args

from cibuildwheel.logger import log
from cibuildwheel.util.helpers import parse_key_value_string

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Sequence

BuildFrontendName = Literal["pip", "build", "build[uv]", "uv"]


Expand Down
14 changes: 9 additions & 5 deletions cibuildwheel/logger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

__lazy_modules__ = [
"cibuildwheel.ci",
"codecs",
"collections",
"collections.abc",
"contextlib",
"functools",
"hashlib",
Expand All @@ -27,15 +28,18 @@
import sys
import textwrap
import time
from collections.abc import Generator
from pathlib import Path
from typing import IO, TYPE_CHECKING, AnyStr, Final, Literal
from typing import Final

import humanize

from cibuildwheel.ci import CIProvider, detect_ci_provider, filter_ansi_codes

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Generator
from typing import IO, AnyStr, Literal

from cibuildwheel.options import Options

FoldPattern = tuple[str, str]
Expand Down Expand Up @@ -252,7 +256,7 @@ def error(self, error: BaseException | str) -> None:
print(f"cibuildwheel: {c.bright_red}error{c.end}: {error}\n", file=sys.stderr)

@contextlib.contextmanager
def print_summary(self, *, options: "Options") -> Generator[None, None, None]:
def print_summary(self, *, options: Options) -> Generator[None, None, None]:
start = time.time()
yield
duration = time.time() - start
Expand Down Expand Up @@ -310,7 +314,7 @@ def _fold_group_identifier(name: str) -> str:
# lowercase, shorten
return identifier.lower()[:20]

def _github_step_summary(self, duration: float, options: "Options") -> str:
def _github_step_summary(self, duration: float, options: Options) -> str:
"""
Returns the GitHub step summary, in markdown format.
"""
Expand Down
20 changes: 12 additions & 8 deletions cibuildwheel/oci_container.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

__lazy_modules__ = [
"cibuildwheel.ci",
"cibuildwheel.errors",
"cibuildwheel.logger",
"cibuildwheel.typing",
"cibuildwheel.util.cmd",
"cibuildwheel.util.helpers",
"collections",
"collections.abc",
"io",
"json",
"os",
Expand All @@ -17,7 +17,6 @@
"subprocess",
"sys",
"textwrap",
"types",
"uuid",
]

Expand All @@ -33,19 +32,24 @@
import textwrap
import typing
import uuid
from collections.abc import Mapping, Sequence
from enum import Enum
from pathlib import Path, PurePath, PurePosixPath
from types import TracebackType
from typing import IO, Literal, Self, assert_never
from typing import Literal, assert_never

from cibuildwheel.ci import CIProvider, detect_ci_provider
from cibuildwheel.errors import OCIEngineTooOldError
from cibuildwheel.logger import log
from cibuildwheel.typing import PathOrStr
from cibuildwheel.util.cmd import call
from cibuildwheel.util.helpers import FlexibleVersion, parse_key_value_string, strtobool

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Mapping, Sequence
from types import TracebackType
from typing import IO, Self

from cibuildwheel.typing import PathOrStr

ContainerEngineName = Literal["docker", "podman"]


Expand All @@ -60,7 +64,7 @@ class OCIPlatform(Enum):
S390X = "linux/s390x"

@classmethod
def native(cls) -> "OCIPlatform":
def native(cls) -> OCIPlatform:
"""Return the current OCI platform, or raise ValueError if unknown."""
arch = platform.machine().lower()
mapping = {
Expand Down
8 changes: 7 additions & 1 deletion cibuildwheel/options.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

__lazy_modules__ = [
"cibuildwheel.architecture",
"cibuildwheel.environment",
Expand Down Expand Up @@ -35,7 +37,7 @@
import tomllib
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence, Set
from pathlib import Path
from typing import Any, Final, Literal, Self, assert_never
from typing import Final, assert_never

from packaging.specifiers import SpecifierSet

Expand All @@ -52,6 +54,10 @@
from cibuildwheel.util.helpers import format_safe, parse_key_value_string, strtobool, unwrap
from cibuildwheel.util.packaging import DependencyConstraints

TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any, Literal, Self

MANYLINUX_ARCHS: Final[tuple[str, ...]] = (
"x86_64",
"i686",
Expand Down
3 changes: 2 additions & 1 deletion cibuildwheel/platforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
__lazy_modules__ = ["sys"]

import sys
from typing import TYPE_CHECKING, Final, Protocol
from typing import Final, Protocol

from cibuildwheel import errors
from cibuildwheel.platforms import android, ios, linux, macos, pyodide, windows

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Sequence
from pathlib import Path
Expand Down
Loading
Loading