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 a comprehensive command-line interface for building Python wheels across multiple platforms and architectures.
The primary entry point for cibuildwheel operations.
def main() -> None:
"""
Main CLI entry point for cibuildwheel.
Parses command line arguments, validates configuration,
and orchestrates the wheel building process.
Raises:
FatalError: On configuration errors or build failures
"""
def main_inner(global_options: GlobalOptions) -> None:
"""
Internal main function that performs the actual build logic.
Same as main() but raises FatalError exceptions rather than
exiting directly, allowing for custom error handling.
Args:
global_options: Global build options and configuration
Raises:
FatalError: On configuration errors or build failures
"""cibuildwheel --platform <platform>Choose the target platform for wheel building:
auto (default): Auto-detect current platformlinux: Build for Linux using containersmacos: Build for macOS (requires macOS runner)windows: Build for Windows (requires Windows runner)pyodide: Build for Pyodide WebAssemblyandroid: Build for Androidios: Build for iOS (requires macOS runner)cibuildwheel --archs <architectures>Specify target CPU architectures (comma-separated):
auto (default): Build for architectures natively supportednative: Build only for the current machine's architectureall: Build for all supported architectures on the platformauto64: Build for 64-bit architectures onlyauto32: Build for 32-bit architectures onlyx86_64,aarch64,arm64,i686,etc.cibuildwheel --only <identifier>Force building a single wheel by its build identifier (e.g., cp311-linux_x86_64). This overrides CIBW_BUILD/CIBW_SKIP settings.
cibuildwheel --enable <group>Enable additional categories of builds (can be used multiple times):
cpython-prerelease: Include CPython prerelease versionspypy: Include PyPy buildsgraalpy: Include GraalPy buildscpython-freethreading: Include free-threaded CPythoncibuildwheel --output-dir <directory>Specify destination folder for built wheels (default: wheelhouse).
cibuildwheel --config-file <path>Specify TOML configuration file path. Default is {package}/pyproject.toml if it exists.
cibuildwheel [PACKAGE]Path to the package directory or SDist file. Default is the current working directory.
cibuildwheel --print-build-identifiersPrint the build identifiers that match the current configuration and exit without building.
cibuildwheel --clean-cacheClear the cibuildwheel cache directory and exit.
cibuildwheel --allow-emptyDon't report an error if no wheels match the build selection criteria.
cibuildwheel --debug-tracebackPrint full Python tracebacks for all errors (useful for debugging).
# Build wheels for current platform
cibuildwheel
# Build for specific platform
cibuildwheel --platform linux
# Build specific Python versions only
cibuildwheel --only cp311-linux_x86_64# Build for multiple architectures
cibuildwheel --archs x86_64,aarch64
# Build for all 64-bit architectures
cibuildwheel --archs auto64
# Build for Linux with emulation
cibuildwheel --platform linux --archs x86_64,aarch64,ppc64le# Use custom config file
cibuildwheel --config-file custom-build.toml
# Custom output directory
cibuildwheel --output-dir dist/wheels
# Enable prerelease Python versions
cibuildwheel --enable cpython-prerelease
# Debug mode with full tracebacks
cibuildwheel --debug-traceback# GitHub Actions matrix build
cibuildwheel --platform ${{ matrix.platform }} --output-dir wheelhouse
# Build from SDist
cibuildwheel package-1.0.0.tar.gz --output-dir wheels# See what would be built
cibuildwheel --print-build-identifiers
# Clean cache if needed
cibuildwheel --clean-cache
# Allow empty builds (useful for conditional CI)
cibuildwheel --allow-emptyThe cibuildwheel command returns specific exit codes for different error conditions:
0: Success1: General fatal error2: Configuration error3: No builds matched selection criteria4: Deprecated configuration detected5: Non-platform wheel detected6: Wheel already exists (when configured to fail)7: Container engine too old8: Wheel repair step failedMany CLI options can also be controlled via environment variables with the CIBW_ prefix:
CIBW_PLATFORM: Equivalent to --platformCIBW_ARCHS: Equivalent to --archsCIBW_OUTPUT_DIR: Equivalent to --output-dirCIBW_CONFIG_FILE: Equivalent to --config-fileCIBW_DEBUG_TRACEBACK: Equivalent to --debug-tracebackPlus many more configuration options for fine-tuning the build process.
Install with Tessl CLI
npx tessl i tessl/pypi-cibuildwheel