Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
exclude: ^cibuildwheel/resources/android/android.patch$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 6fec9b7edb08fd9989088709d864a7826dc74e80 # frozen: v0.15.12
rev: 0c7b6c989466a93942def1f84baf36ddfcd60c83 # frozen: v0.15.14
hooks:
- id: ruff-check
args: ["--fix"]
Expand Down
7 changes: 6 additions & 1 deletion bin/inspect_all_known_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
the results without the `--online` setting.
"""

from __future__ import annotations

import ast
from collections.abc import Iterable, Iterator
from pathlib import Path
from typing import TYPE_CHECKING

import click
import yaml
Expand All @@ -35,6 +37,9 @@

from cibuildwheel.projectfiles import Analyzer

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator

DIR = Path(__file__).parent.resolve()


Expand Down
8 changes: 6 additions & 2 deletions bin/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@
git diff
"""

from __future__ import annotations

import builtins
import functools
import textwrap
import urllib.error
import urllib.request
import xml.dom.minidom
from collections.abc import Iterable, Mapping, Sequence
from datetime import UTC, datetime
from io import StringIO
from pathlib import Path
from typing import Any, Self, TextIO
from typing import TYPE_CHECKING, Any, Self, TextIO

import click
import yaml
from github import Auth, Github, GithubException

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, Sequence

ICONS = (
"github",
"azurepipelines",
Expand Down
8 changes: 5 additions & 3 deletions bin/update_pythons.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
# [tool.uv.sources]
# cibuildwheel = { path = ".." }
# ///

from __future__ import annotations

import difflib
import logging
import operator
import re
import tomllib
from collections.abc import Mapping, MutableMapping
from pathlib import Path
from typing import Any, Final, Literal, TypedDict
from typing import TYPE_CHECKING, Any, Final, Literal, TypedDict
from xml.etree import ElementTree as ET

import click
Expand All @@ -35,6 +34,9 @@
from cibuildwheel.extra import dump_python_configurations, get_pyodide_xbuildenv_info
from cibuildwheel.platforms.android import android_triplet

if TYPE_CHECKING:
from collections.abc import Mapping, MutableMapping

log = logging.getLogger("cibw")

# Looking up the dir instead of using utils.resources_dir
Expand Down
8 changes: 6 additions & 2 deletions cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import argparse
import contextlib
import dataclasses
Expand All @@ -8,10 +10,9 @@
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
from typing import TYPE_CHECKING, Any, Literal, TextIO

import cibuildwheel
from cibuildwheel import errors
Expand All @@ -27,6 +28,9 @@
from cibuildwheel.util.helpers import strtobool
from cibuildwheel.util.resources import read_all_configs

if TYPE_CHECKING:
from collections.abc import Generator, Iterable, Sequence


@dataclasses.dataclass
class GlobalOptions:
Expand Down
2 changes: 1 addition & 1 deletion cibuildwheel/_compat/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import sys
import tarfile
from typing import TYPE_CHECKING

TYPE_CHECKING = False
if TYPE_CHECKING:
from pathlib import Path

Expand Down
11 changes: 8 additions & 3 deletions cibuildwheel/architecture.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from __future__ import annotations

import platform as platform_module
import re
import shutil
import subprocess
import sys
import typing
from collections.abc import Set
from enum import StrEnum, auto
from typing import Final, Literal, Self
from typing import TYPE_CHECKING, Final, Literal, Self

from cibuildwheel import errors
from cibuildwheel.typing import PlatformName

if TYPE_CHECKING:
from collections.abc import Set

from cibuildwheel.typing import PlatformName

PRETTY_NAMES: Final[dict[PlatformName, str]] = {
"linux": "Linux",
Expand Down
7 changes: 6 additions & 1 deletion cibuildwheel/audit.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from __future__ import annotations

import subprocess
import sys
from pathlib import Path
from typing import TYPE_CHECKING

from cibuildwheel import errors
from cibuildwheel.logger import log
from cibuildwheel.options import BuildOptions
from cibuildwheel.util.cmd import call, shell
from cibuildwheel.util.helpers import prepare_command
from cibuildwheel.util.packaging import is_abi3_wheel
from cibuildwheel.venv import activate_virtualenv, find_uv, virtualenv

if TYPE_CHECKING:
from cibuildwheel.options import BuildOptions


def run_audit(
*,
Expand Down
21 changes: 13 additions & 8 deletions cibuildwheel/bashlex_eval.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from __future__ import annotations

import dataclasses
import subprocess
from collections.abc import (
Callable,
Iterable,
Mapping,
Sequence,
)
from typing import TYPE_CHECKING

import bashlex

# a function that takes a command and the environment, and returns the result
EnvironmentExecutor = Callable[[list[str], dict[str, str]], str]
if TYPE_CHECKING:
from collections.abc import (
Callable,
Iterable,
Mapping,
Sequence,
)

# a function that takes a command and the environment, and returns the result
EnvironmentExecutor = Callable[[list[str], dict[str, str]], str]


def local_environment_executor(command: Sequence[str], env: Mapping[str, str]) -> str:
Expand Down
8 changes: 6 additions & 2 deletions cibuildwheel/environment.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from __future__ import annotations

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

import bashlex
import bashlex.errors

from cibuildwheel import bashlex_eval

if TYPE_CHECKING:
from collections.abc import Mapping, Sequence


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

from __future__ import annotations

import json
import time
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 TYPE_CHECKING, Any, NotRequired, Protocol

from cibuildwheel import __version__ as cibw_version

if TYPE_CHECKING:
from collections.abc import Mapping, Sequence


__all__ = ("Printable", "dump_python_configurations")


Expand Down
11 changes: 8 additions & 3 deletions cibuildwheel/frontend.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from __future__ import annotations

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

from cibuildwheel.typing import PathOrStr
from cibuildwheel.util.helpers import parse_key_value_string, prepare_command

if TYPE_CHECKING:
from collections.abc import Sequence

from cibuildwheel.typing import PathOrStr

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


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

import codecs
import contextlib
import dataclasses
Expand All @@ -9,19 +11,20 @@
import sys
import textwrap
import time
from collections.abc import Generator
from pathlib import Path
from typing import IO, AnyStr, Final, Literal
from typing import IO, TYPE_CHECKING, AnyStr, Final, Literal

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 cibuildwheel.options import Options

FoldPattern = tuple[str, str]
FoldPattern = tuple[str, str]

DEFAULT_FOLD_PATTERN: Final[FoldPattern] = ("{name}", "")
FOLD_PATTERNS: Final[dict[str, FoldPattern]] = {
"azure": ("##[group]{name}", "##[endgroup]"),
Expand Down Expand Up @@ -235,7 +238,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 @@ -293,7 +296,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
16 changes: 11 additions & 5 deletions cibuildwheel/oci_container.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import dataclasses
import io
import json
Expand All @@ -10,19 +12,23 @@
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 pathlib import PurePosixPath
from typing import IO, TYPE_CHECKING, Literal, Self, 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

if TYPE_CHECKING:
from collections.abc import Mapping, Sequence
from pathlib import Path, PurePath
from types import TracebackType

from cibuildwheel.typing import PathOrStr

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


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

import collections
import configparser
import contextlib
Expand All @@ -8,9 +10,9 @@
import shlex
import textwrap
import tomllib
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence, Set
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import Any, Final, Literal, Self, assert_never
from typing import TYPE_CHECKING, Any, Final, Literal, Self, assert_never

from packaging.specifiers import SpecifierSet

Expand All @@ -27,6 +29,9 @@
from cibuildwheel.util.helpers import format_safe, parse_key_value_string, strtobool, unwrap
from cibuildwheel.util.packaging import DependencyConstraints

if TYPE_CHECKING:
from collections.abc import Callable, Generator, Iterable, Set

MANYLINUX_ARCHS: Final[tuple[str, ...]] = (
"x86_64",
"i686",
Expand Down
Loading
Loading