Build Python wheels on CI with minimal configuration.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Cibuildwheel provides comprehensive architecture support with automatic detection, cross-compilation capabilities, and architecture-specific build configuration.
Complete enumeration of all supported CPU architectures across platforms.
class Architecture(StrEnum):
# Cross-platform architectures
x86_64 = "x86_64"
# Linux-specific architectures
i686 = "i686"
aarch64 = "aarch64"
ppc64le = "ppc64le"
s390x = "s390x"
armv7l = "armv7l"
riscv64 = "riscv64"
# macOS-specific architectures
universal2 = "universal2"
arm64 = "arm64"
# Windows-specific architectures
x86 = "x86"
AMD64 = "AMD64"
ARM64 = "ARM64"
# WebAssembly architecture
wasm32 = "wasm32"
# Android architecture
arm64_v8a = "arm64_v8a"
# iOS architectures
arm64_iphoneos = "arm64_iphoneos"
arm64_iphonesimulator = "arm64_iphonesimulator"
x86_64_iphonesimulator = "x86_64_iphonesimulator"Parse architecture specifications from configuration strings.
@staticmethod
def parse_config(config: str, platform: PlatformName) -> set[Architecture]:
"""
Parse architecture configuration string for a specific platform.
Args:
config: Architecture specification string (e.g., "x86_64,aarch64" or "auto")
platform: Target platform name
Returns:
Set of Architecture enums matching the specification
Raises:
ConfigurationError: If architecture specification is invalid
"""Detect the native architecture of the current system.
@staticmethod
def native_arch(platform: PlatformName) -> Architecture | None:
"""
Get the native architecture for the specified platform.
Args:
platform: Target platform name
Returns:
Native Architecture for the platform, or None if not determinable
"""Get architecture sets based on automatic selection criteria.
@staticmethod
def auto_archs(platform: PlatformName) -> set[Architecture]:
"""
Get the set of architectures that would be built by default ('auto').
Args:
platform: Target platform name
Returns:
Set of architectures for automatic builds on this platform
"""
@staticmethod
def all_archs(platform: PlatformName) -> set[Architecture]:
"""
Get all supported architectures for a platform.
Args:
platform: Target platform name
Returns:
Set of all supported architectures for this platform
"""
@staticmethod
def bitness_archs(platform: PlatformName, bitness: Literal["64", "32"]) -> set[Architecture]:
"""
Get architectures by bit width for a platform.
Args:
platform: Target platform name
bitness: Either "64" for 64-bit or "32" for 32-bit architectures
Returns:
Set of architectures matching the specified bit width
"""Convert architecture names between different platform naming conventions.
def arch_synonym(arch: str, from_platform: PlatformName, to_platform: PlatformName) -> str | None:
"""
Translate architecture name from one platform's convention to another's.
Args:
arch: Architecture name in source platform's convention
from_platform: Source platform
to_platform: Target platform
Returns:
Architecture name in target platform's convention, or None if no translation exists
"""Validate that architectures are supported on the target platform.
def allowed_architectures_check(platform: PlatformName, architectures: set[Architecture]) -> None:
"""
Validate that all specified architectures are supported on the platform.
Args:
platform: Target platform name
architectures: Set of architectures to validate
Raises:
ValueError: If any architecture is not supported on the platform
"""# Configuration string parsing
from cibuildwheel.architecture import Architecture
# Parse specific architectures
archs = Architecture.parse_config("x86_64,aarch64", "linux")
# Returns: {Architecture.x86_64, Architecture.aarch64}
# Parse automatic selection
archs = Architecture.parse_config("auto", "linux")
# Returns: {Architecture.x86_64} (on x86_64 host)
# Parse all architectures
archs = Architecture.parse_config("all", "linux")
# Returns: {Architecture.x86_64, Architecture.i686, Architecture.aarch64, ...}# Get default architectures for each platform
linux_auto = Architecture.auto_archs("linux") # {x86_64} on x86_64 host
macos_auto = Architecture.auto_archs("macos") # {x86_64} on Intel, {arm64} on Apple Silicon
windows_auto = Architecture.auto_archs("windows") # {AMD64} on 64-bit, {x86} on 32-bit# Linux cross-compilation (requires emulation)
CIBW_ARCHS_LINUX = "x86_64 aarch64 ppc64le"
# macOS universal binaries
CIBW_ARCHS_MACOS = "universal2"
# Windows cross-compilation
CIBW_ARCHS_WINDOWS = "AMD64 ARM64"from cibuildwheel.architecture import allowed_architectures_check, Architecture
# Validate architecture support
try:
allowed_architectures_check("linux", {Architecture.x86_64, Architecture.aarch64})
# Success - both architectures supported on Linux
except ValueError as e:
print(f"Architecture validation failed: {e}")
# This would raise an error
try:
allowed_architectures_check("windows", {Architecture.aarch64})
# ValueError - aarch64 not supported on Windows (use ARM64 instead)
except ValueError:
passfrom cibuildwheel.architecture import arch_synonym
# Translate between platform conventions
windows_arch = arch_synonym("x86_64", "linux", "windows")
# Returns: "AMD64"
linux_arch = arch_synonym("AMD64", "windows", "linux")
# Returns: "x86_64"
ios_arch = arch_synonym("arm64", "macos", "ios")
# Returns: "arm64_iphoneos"Cibuildwheel supports cross-compilation through emulation on Linux:
The universal2 architecture creates fat binaries containing both Intel and Apple Silicon code:
# Build universal binaries
CIBW_ARCHS_MACOS = "universal2"
# Or build separate architectures and combine later
CIBW_ARCHS_MACOS = "x86_64 arm64"Different configurations can be applied per architecture:
[tool.cibuildwheel.linux]
archs = ["x86_64", "aarch64"]
[tool.cibuildwheel.windows]
archs = ["AMD64"]
skip = ["*-win32"] # Skip 32-bit builds
[tool.cibuildwheel.macos]
archs = ["universal2"]Install with Tessl CLI
npx tessl i tessl/pypi-cibuildwheel