diff --git a/cibuildwheel/architecture.py b/cibuildwheel/architecture.py index bf0af268..ad611594 100644 --- a/cibuildwheel/architecture.py +++ b/cibuildwheel/architecture.py @@ -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", diff --git a/cibuildwheel/ci.py b/cibuildwheel/ci.py index 500d435e..ae111de3 100644 --- a/cibuildwheel/ci.py +++ b/cibuildwheel/ci.py @@ -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)") diff --git a/cibuildwheel/environment.py b/cibuildwheel/environment.py index 4e603f99..7e371b28 100644 --- a/cibuildwheel/environment.py +++ b/cibuildwheel/environment.py @@ -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): diff --git a/cibuildwheel/frontend.py b/cibuildwheel/frontend.py index 6f54de55..eb55f4f6 100644 --- a/cibuildwheel/frontend.py +++ b/cibuildwheel/frontend.py @@ -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"] diff --git a/cibuildwheel/logger.py b/cibuildwheel/logger.py index dad70309..e2b5776c 100644 --- a/cibuildwheel/logger.py +++ b/cibuildwheel/logger.py @@ -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}", "") diff --git a/cibuildwheel/oci_container.py b/cibuildwheel/oci_container.py index 99351461..55ab99e6 100644 --- a/cibuildwheel/oci_container.py +++ b/cibuildwheel/oci_container.py @@ -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"] diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index af946a88..d1efbbdc 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -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", diff --git a/cibuildwheel/platforms/android.py b/cibuildwheel/platforms/android.py index 5f4839e5..b4c237ca 100644 --- a/cibuildwheel/platforms/android.py +++ b/cibuildwheel/platforms/android.py @@ -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", diff --git a/cibuildwheel/platforms/ios.py b/cibuildwheel/platforms/ios.py index bdb2ad8b..33e6899c 100644 --- a/cibuildwheel/platforms/ios.py +++ b/cibuildwheel/platforms/ios.py @@ -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) diff --git a/cibuildwheel/platforms/linux.py b/cibuildwheel/platforms/linux.py index 7b9b0c37..595835f4 100644 --- a/cibuildwheel/platforms/linux.py +++ b/cibuildwheel/platforms/linux.py @@ -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, diff --git a/cibuildwheel/platforms/macos.py b/cibuildwheel/platforms/macos.py index e5b4d9e3..ad084fd6 100644 --- a/cibuildwheel/platforms/macos.py +++ b/cibuildwheel/platforms/macos.py @@ -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 diff --git a/cibuildwheel/platforms/pyodide.py b/cibuildwheel/platforms/pyodide.py index 30d5f25d..15612a85 100644 --- a/cibuildwheel/platforms/pyodide.py +++ b/cibuildwheel/platforms/pyodide.py @@ -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") diff --git a/cibuildwheel/platforms/windows.py b/cibuildwheel/platforms/windows.py index d28643b4..18d400a9 100644 --- a/cibuildwheel/platforms/windows.py +++ b/cibuildwheel/platforms/windows.py @@ -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( diff --git a/cibuildwheel/schema.py b/cibuildwheel/schema.py index ef8f603b..ec070278 100644 --- a/cibuildwheel/schema.py +++ b/cibuildwheel/schema.py @@ -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]: diff --git a/cibuildwheel/util/cmd.py b/cibuildwheel/util/cmd.py index 413d6f80..aba6cf17 100644 --- a/cibuildwheel/util/cmd.py +++ b/cibuildwheel/util/cmd.py @@ -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") diff --git a/cibuildwheel/util/file.py b/cibuildwheel/util/file.py index b93a5e50..04e40f3d 100644 --- a/cibuildwheel/util/file.py +++ b/cibuildwheel/util/file.py @@ -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( diff --git a/cibuildwheel/util/helpers.py b/cibuildwheel/util/helpers.py index adefb495..6e17cb2e 100644 --- a/cibuildwheel/util/helpers.py +++ b/cibuildwheel/util/helpers.py @@ -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: diff --git a/cibuildwheel/util/packaging.py b/cibuildwheel/util/packaging.py index c3d8c21d..abb8badd 100644 --- a/cibuildwheel/util/packaging.py +++ b/cibuildwheel/util/packaging.py @@ -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) diff --git a/cibuildwheel/util/resources.py b/cibuildwheel/util/resources.py index 4be747a9..c69fd949 100644 --- a/cibuildwheel/util/resources.py +++ b/cibuildwheel/util/resources.py @@ -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" diff --git a/cibuildwheel/venv.py b/cibuildwheel/venv.py index 49f4dea7..dd4fe90a 100644 --- a/cibuildwheel/venv.py +++ b/cibuildwheel/venv.py @@ -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") diff --git a/pyproject.toml b/pyproject.toml index f2b5169f..24323b03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"]