chore: use absolute imports (#2796)

chore: use abosolute imports

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
This commit is contained in:
Henry Schreiner
2026-03-24 09:20:41 -04:00
committed by GitHub
parent 8a2ca0ce78
commit cb1fdd0316
21 changed files with 127 additions and 134 deletions
+1 -2
View File
@@ -9,8 +9,7 @@ from enum import StrEnum, auto
from typing import Final, Literal
from cibuildwheel import errors
from .typing import PlatformName
from cibuildwheel.typing import PlatformName
PRETTY_NAMES: Final[dict[PlatformName, str]] = {
"linux": "Linux",
+1 -1
View File
@@ -2,7 +2,7 @@ import os
import re
from enum import Enum
from .util.helpers import strtobool
from cibuildwheel.util.helpers import strtobool
ANSI_CODE_REGEX = re.compile(r"(\033\[[0-9;]*m)")
+1 -1
View File
@@ -5,7 +5,7 @@ from typing import Any, Protocol
import bashlex
import bashlex.errors
from . import bashlex_eval
from cibuildwheel import bashlex_eval
class EnvironmentParseError(Exception):
+2 -2
View File
@@ -4,8 +4,8 @@ import typing
from collections.abc import Sequence
from typing import Literal, Self, get_args
from .logger import log
from .util.helpers import parse_key_value_string
from cibuildwheel.logger import log
from cibuildwheel.util.helpers import parse_key_value_string
BuildFrontendName = Literal["pip", "build", "build[uv]", "uv"]
+2 -2
View File
@@ -15,10 +15,10 @@ from typing import IO, TYPE_CHECKING, AnyStr, Final, Literal
import humanize
from .ci import CIProvider, detect_ci_provider, filter_ansi_codes
from cibuildwheel.ci import CIProvider, detect_ci_provider, filter_ansi_codes
if TYPE_CHECKING:
from .options import Options
from cibuildwheel.options import Options
FoldPattern = tuple[str, str]
DEFAULT_FOLD_PATTERN: Final[FoldPattern] = ("{name}", "")
+6 -6
View File
@@ -16,12 +16,12 @@ from pathlib import Path, PurePath, PurePosixPath
from types import TracebackType
from typing import IO, Literal, Self, assert_never
from .ci import CIProvider, detect_ci_provider
from .errors import OCIEngineTooOldError
from .logger import log
from .typing import PathOrStr
from .util.cmd import call
from .util.helpers import FlexibleVersion, parse_key_value_string, strtobool
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
ContainerEngineName = Literal["docker", "podman"]
+12 -12
View File
@@ -14,18 +14,18 @@ from typing import Any, Final, Literal, Self, assert_never
from packaging.specifiers import SpecifierSet
from . import errors
from .architecture import Architecture
from .environment import EnvironmentParseError, ParsedEnvironment, parse_environment
from .frontend import BuildFrontendConfig
from .logger import log
from .oci_container import OCIContainerEngineConfig
from .projectfiles import get_requires_python_str, resolve_dependency_groups
from .selector import BuildSelector, EnableGroup, TestSelector, selector_matches
from .typing import PLATFORMS, PlatformName
from .util import resources
from .util.helpers import format_safe, parse_key_value_string, strtobool, unwrap
from .util.packaging import DependencyConstraints
from cibuildwheel import errors
from cibuildwheel.architecture import Architecture
from cibuildwheel.environment import EnvironmentParseError, ParsedEnvironment, parse_environment
from cibuildwheel.frontend import BuildFrontendConfig
from cibuildwheel.logger import log
from cibuildwheel.oci_container import OCIContainerEngineConfig
from cibuildwheel.projectfiles import get_requires_python_str, resolve_dependency_groups
from cibuildwheel.selector import BuildSelector, EnableGroup, TestSelector, selector_matches
from cibuildwheel.typing import PLATFORMS, PlatformName
from cibuildwheel.util import resources
from cibuildwheel.util.helpers import format_safe, parse_key_value_string, strtobool, unwrap
from cibuildwheel.util.packaging import DependencyConstraints
MANYLINUX_ARCHS: Final[tuple[str, ...]] = (
"x86_64",
+13 -13
View File
@@ -22,19 +22,19 @@ from elftools.common.exceptions import ELFError
from elftools.elf.elffile import ELFFile
from filelock import FileLock
from .. import errors, platforms # pylint: disable=cyclic-import
from ..architecture import Architecture, arch_synonym
from ..frontend import get_build_frontend_extra_flags, parse_config_settings
from ..logger import log
from ..options import BuildOptions, Options
from ..selector import BuildSelector
from ..util import resources
from ..util.cmd import call, shell
from ..util.file import CIBW_CACHE_PATH, copy_test_sources, download, move_file
from ..util.helpers import prepare_command
from ..util.packaging import find_compatible_wheel
from ..util.python_build_standalone import create_python_build_standalone_environment
from ..venv import constraint_flags, find_uv, virtualenv
from cibuildwheel import errors, platforms # pylint: disable=cyclic-import
from cibuildwheel.architecture import Architecture, arch_synonym
from cibuildwheel.frontend import get_build_frontend_extra_flags, parse_config_settings
from cibuildwheel.logger import log
from cibuildwheel.options import BuildOptions, Options
from cibuildwheel.selector import BuildSelector
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call, shell
from cibuildwheel.util.file import CIBW_CACHE_PATH, copy_test_sources, download, move_file
from cibuildwheel.util.helpers import prepare_command
from cibuildwheel.util.packaging import find_compatible_wheel
from cibuildwheel.util.python_build_standalone import create_python_build_standalone_environment
from cibuildwheel.venv import constraint_flags, find_uv, virtualenv
ANDROID_TRIPLET = {
"arm64_v8a": "aarch64-linux-android",
+14 -24
View File
@@ -13,34 +13,24 @@ from typing import TYPE_CHECKING, assert_never
from filelock import FileLock
from .. import errors
from ..frontend import (
BuildFrontendName,
get_build_frontend_extra_flags,
)
from ..logger import log
from ..util import resources
from ..util.cmd import call, shell, split_command
from ..util.file import (
CIBW_CACHE_PATH,
copy_test_sources,
download,
move_file,
)
from ..util.helpers import prepare_command, unwrap_preserving_paragraphs
from ..util.packaging import (
find_compatible_wheel,
)
from ..venv import constraint_flags, virtualenv
from .macos import install_cpython as install_build_cpython
from cibuildwheel import errors
from cibuildwheel.frontend import BuildFrontendName, get_build_frontend_extra_flags
from cibuildwheel.logger import log
from cibuildwheel.platforms.macos import install_cpython as install_build_cpython
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call, shell, split_command
from cibuildwheel.util.file import CIBW_CACHE_PATH, copy_test_sources, download, move_file
from cibuildwheel.util.helpers import prepare_command, unwrap_preserving_paragraphs
from cibuildwheel.util.packaging import find_compatible_wheel
from cibuildwheel.venv import constraint_flags, virtualenv
if TYPE_CHECKING:
from collections.abc import Sequence, Set
from ..architecture import Architecture
from ..environment import ParsedEnvironment
from ..options import Options
from ..selector import BuildSelector
from cibuildwheel.architecture import Architecture
from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.options import Options
from cibuildwheel.selector import BuildSelector
@dataclasses.dataclass(frozen=True, kw_only=True)
+12 -12
View File
@@ -8,20 +8,20 @@ from collections.abc import Iterable, Iterator, Sequence, Set
from pathlib import Path, PurePath, PurePosixPath
from typing import TYPE_CHECKING, assert_never
from .. import errors
from ..architecture import Architecture
from ..frontend import get_build_frontend_extra_flags
from ..logger import log
from ..oci_container import OCIContainer, OCIContainerEngineConfig, OCIPlatform
from ..options import BuildOptions, Options
from ..selector import BuildSelector
from ..util import resources
from ..util.file import copy_test_sources
from ..util.helpers import prepare_command, unwrap
from ..util.packaging import find_compatible_wheel
from cibuildwheel import errors
from cibuildwheel.architecture import Architecture
from cibuildwheel.frontend import get_build_frontend_extra_flags
from cibuildwheel.logger import log
from cibuildwheel.oci_container import OCIContainer, OCIContainerEngineConfig, OCIPlatform
from cibuildwheel.options import BuildOptions, Options
from cibuildwheel.selector import BuildSelector
from cibuildwheel.util import resources
from cibuildwheel.util.file import copy_test_sources
from cibuildwheel.util.helpers import prepare_command, unwrap
from cibuildwheel.util.packaging import find_compatible_wheel
if TYPE_CHECKING:
from ..typing import PathOrStr
from cibuildwheel.typing import PathOrStr
ARCHITECTURE_OCI_PLATFORM_MAP = {
Architecture.x86_64: OCIPlatform.AMD64,
+14 -19
View File
@@ -15,25 +15,20 @@ from typing import Literal, assert_never
from filelock import FileLock
from packaging.version import Version
from .. import errors
from ..architecture import Architecture
from ..ci import detect_ci_provider
from ..environment import ParsedEnvironment
from ..frontend import BuildFrontendName, get_build_frontend_extra_flags
from ..logger import log
from ..options import Options
from ..selector import BuildSelector
from ..util import resources
from ..util.cmd import call, shell
from ..util.file import (
CIBW_CACHE_PATH,
copy_test_sources,
download,
move_file,
)
from ..util.helpers import prepare_command, unwrap
from ..util.packaging import find_compatible_wheel, get_pip_version
from ..venv import constraint_flags, find_uv, virtualenv
from cibuildwheel import errors
from cibuildwheel.architecture import Architecture
from cibuildwheel.ci import detect_ci_provider
from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.frontend import BuildFrontendName, get_build_frontend_extra_flags
from cibuildwheel.logger import log
from cibuildwheel.options import Options
from cibuildwheel.selector import BuildSelector
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call, shell
from cibuildwheel.util.file import CIBW_CACHE_PATH, copy_test_sources, download, move_file
from cibuildwheel.util.helpers import prepare_command, unwrap
from cibuildwheel.util.packaging import find_compatible_wheel, get_pip_version
from cibuildwheel.venv import constraint_flags, find_uv, virtualenv
@functools.cache
+14 -14
View File
@@ -14,16 +14,16 @@ from typing import Final, TypedDict
from filelock import FileLock
from .. import errors
from ..architecture import Architecture
from ..environment import ParsedEnvironment
from ..frontend import get_build_frontend_extra_flags
from ..logger import log
from ..options import Options
from ..selector import BuildSelector
from ..util import resources
from ..util.cmd import call, shell
from ..util.file import (
from cibuildwheel import errors
from cibuildwheel.architecture import Architecture
from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.frontend import get_build_frontend_extra_flags
from cibuildwheel.logger import log
from cibuildwheel.options import Options
from cibuildwheel.selector import BuildSelector
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call, shell
from cibuildwheel.util.file import (
CIBW_CACHE_PATH,
copy_test_sources,
download,
@@ -31,13 +31,13 @@ from ..util.file import (
extract_zip,
move_file,
)
from ..util.helpers import prepare_command, unwrap, unwrap_preserving_paragraphs
from ..util.packaging import find_compatible_wheel, get_pip_version
from ..util.python_build_standalone import (
from cibuildwheel.util.helpers import prepare_command, unwrap, unwrap_preserving_paragraphs
from cibuildwheel.util.packaging import find_compatible_wheel, get_pip_version
from cibuildwheel.util.python_build_standalone import (
PythonBuildStandaloneError,
create_python_build_standalone_environment,
)
from ..venv import constraint_flags, virtualenv
from cibuildwheel.venv import constraint_flags, virtualenv
IS_WIN: Final[bool] = sys.platform.startswith("win")
+19 -13
View File
@@ -12,19 +12,25 @@ from typing import assert_never
from filelock import FileLock
from .. import errors
from ..architecture import Architecture
from ..environment import ParsedEnvironment
from ..frontend import BuildFrontendName, get_build_frontend_extra_flags
from ..logger import log
from ..options import Options
from ..selector import BuildSelector
from ..util import resources
from ..util.cmd import call, shell
from ..util.file import CIBW_CACHE_PATH, copy_test_sources, download, extract_zip, move_file
from ..util.helpers import prepare_command, unwrap
from ..util.packaging import find_compatible_wheel, get_pip_version
from ..venv import constraint_flags, find_uv, virtualenv
from cibuildwheel import errors
from cibuildwheel.architecture import Architecture
from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.frontend import BuildFrontendName, get_build_frontend_extra_flags
from cibuildwheel.logger import log
from cibuildwheel.options import Options
from cibuildwheel.selector import BuildSelector
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call, shell
from cibuildwheel.util.file import (
CIBW_CACHE_PATH,
copy_test_sources,
download,
extract_zip,
move_file,
)
from cibuildwheel.util.helpers import prepare_command, unwrap
from cibuildwheel.util.packaging import find_compatible_wheel, get_pip_version
from cibuildwheel.venv import constraint_flags, find_uv, virtualenv
def get_nuget_args(
+1 -1
View File
@@ -1,7 +1,7 @@
import json
from typing import Any
from .util import resources
from cibuildwheel.util import resources
def get_schema(tool_name: str = "cibuildwheel") -> dict[str, Any]:
+2 -2
View File
@@ -7,8 +7,8 @@ import typing
from collections.abc import Iterator, Mapping
from typing import Final, Literal
from ..errors import FatalError
from ..typing import PathOrStr
from cibuildwheel.errors import FatalError
from cibuildwheel.typing import PathOrStr
_IS_WIN: Final[bool] = sys.platform.startswith("win")
+1 -1
View File
@@ -12,7 +12,7 @@ from zipfile import ZipFile
import certifi
from platformdirs import user_cache_path
from ..errors import FatalError
from cibuildwheel.errors import FatalError
DEFAULT_CIBW_CACHE_PATH: Final[Path] = user_cache_path(appname="cibuildwheel", appauthor="pypa")
CIBW_CACHE_PATH: Final[Path] = Path(
+1 -1
View File
@@ -7,7 +7,7 @@ import textwrap
from collections import defaultdict
from collections.abc import Sequence
from ..typing import PathOrStr
from cibuildwheel.typing import PathOrStr
def format_safe(template: str, **kwargs: str | os.PathLike[str]) -> str:
+3 -3
View File
@@ -6,9 +6,9 @@ from typing import Any, Literal, Self, TypeVar
from packaging.utils import parse_wheel_filename
from . import resources
from .cmd import call
from .helpers import parse_key_value_string, unwrap
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call
from cibuildwheel.util.helpers import parse_key_value_string, unwrap
@dataclass(kw_only=True)
+1 -1
View File
@@ -3,7 +3,7 @@ import tomllib
from pathlib import Path
from typing import Final
from ..typing import PlatformName
from cibuildwheel.typing import PlatformName
PATH: Final[Path] = Path(__file__).parent.parent / "resources"
INSTALL_CERTIFI_SCRIPT: Final[Path] = PATH / "install_certifi.py"
+3 -3
View File
@@ -12,9 +12,9 @@ from filelock import FileLock
from packaging.requirements import InvalidRequirement, Requirement
from packaging.version import Version
from .util import resources
from .util.cmd import call
from .util.file import CIBW_CACHE_PATH, download
from cibuildwheel.util import resources
from cibuildwheel.util.cmd import call
from cibuildwheel.util.file import CIBW_CACHE_PATH, download
_IS_WIN: Final[bool] = sys.platform.startswith("win")
+4 -1
View File
@@ -211,6 +211,7 @@ extend-select = [
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"TID251", # flake8-tidy-imports.banned-api
"TID252", # flake8-tidy-imports.relative-imports
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
@@ -236,6 +237,7 @@ ignore = [
"PTH123", # open -> Path.open
]
flake8-unused-arguments.ignore-variadic-names = true
flake8-tidy-imports.ban-relative-imports = "all"
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"typing.Mapping".msg = "Use collections.abc.Mapping instead."
@@ -245,7 +247,8 @@ flake8-unused-arguments.ignore-variadic-names = true
"typing.Set".msg = "Use collections.abc.Set instead."
[tool.ruff.lint.per-file-ignores]
"unit_test/*" = ["PLC1901"]
"unit_test/*" = ["PLC1901", "TID252"]
"test/*" = ["TID252"]
"bin/*" = ["TID251"]
"cibuildwheel/resources/install_certifi.py" = ["PTH"]