diff --git a/docs/extra.css b/docs/extra.css
index df7103cea..c8f0953b4 100644
--- a/docs/extra.css
+++ b/docs/extra.css
@@ -47,6 +47,10 @@ h1, h2, h3, h4, h5, h6 {
padding-bottom: 0.2em;
}
+.wy-nav-content {
+ max-width: 900px;
+}
+
.rst-content blockquote {
margin-bottom: 14px;
}
diff --git a/docs/options.md b/docs/options.md
index 3bd90369f..ee2524caf 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -4,7 +4,7 @@
## Build selection
-### `CIBW_PLATFORM` {: #platform}
+### `platform` {: #platform cmd-line env-var }
> Override the auto-detected target platform
@@ -40,13 +40,13 @@ This option can also be set using the [command-line option](#command-line) `--pl
not require `--platform` or `--arch`, and will override any build/skip
configuration.
-### `CIBW_BUILD`, `CIBW_SKIP` {: #build-skip}
+### `build` & `skip` {: #build-skip toml="build, skip" env-var="CIBW_BUILD, CIBW_SKIP" }
> Choose the Python versions to build
List of builds to build and skip. Each build has an identifier like `cp38-manylinux_x86_64` or `cp37-macosx_x86_64` - you can list specific ones to build and cibuildwheel will only build those, and/or list ones to skip and cibuildwheel won't try to build them.
-When both options are specified, both conditions are applied and only builds with a tag that matches `CIBW_BUILD` and does not match `CIBW_SKIP` will be built.
+When both options are specified, both conditions are applied and only builds with a tag that matches `build` and does not match `skip` will be built.
When setting the options, you can use shell-style globbing syntax, as per [fnmatch](https://docs.python.org/3/library/fnmatch.html) with the addition of curly bracket syntax `{option1,option2}`, provided by [bracex](https://pypi.org/project/bracex/). All the build identifiers supported by cibuildwheel are shown below:
@@ -69,80 +69,82 @@ The list of supported and currently selected build identifiers can also be retri
The format is `python_tag-platform_tag`, with tags similar to those in [PEP 425](https://www.python.org/dev/peps/pep-0425/#details).
Windows arm64 platform support is experimental.
-Linux riscv64 platform support is experimental and requires an explicit opt-in through [CIBW_ENABLE](#enable).
+Linux riscv64 platform support is experimental and requires an explicit opt-in through [`enable`](#enable).
See the [cibuildwheel 2 documentation](https://cibuildwheel.pypa.io/en/2.x/) for past end-of-life versions of Python.
#### Examples
-!!! tab examples "Environment variables"
+!!! tab examples "pyproject.toml"
- ```yaml
+ ```toml
+ [tool.cibuildwheel]
# Only build on CPython 3.8
- CIBW_BUILD: cp38-*
+ build = "cp38-*"
# Skip building on CPython 3.8 on the Mac
- CIBW_SKIP: cp38-macosx_x86_64
+ skip = "cp38-macosx_x86_64"
# Skip building on CPython 3.8 on all platforms
- CIBW_SKIP: cp38-*
+ skip = "cp38-*"
# Skip CPython 3.8 on Windows
- CIBW_SKIP: cp38-win*
+ skip = "cp38-win*"
# Skip CPython 3.8 on 32-bit Windows
- CIBW_SKIP: cp38-win32
+ skip = "cp38-win32"
# Skip CPython 3.8 and CPython 3.9
- CIBW_SKIP: cp38-* cp39-*
+ skip = ["cp38-*", "cp39-*"]
# Skip Python 3.8 on Linux
- CIBW_SKIP: cp38-manylinux*
+ skip = "cp38-manylinux*"
# Skip 32-bit builds
- CIBW_SKIP: "*-win32 *-manylinux_i686"
+ skip = ["*-win32", "*-manylinux_i686"]
# Disable building PyPy wheels on all platforms
- CIBW_SKIP: pp*
+ skip = "pp*"
```
- Separate multiple selectors with a space.
-
-!!! tab examples "pyproject.toml"
+!!! tab examples "Environment variables"
- ```toml
- [tool.cibuildwheel]
+ ```yaml
# Only build on CPython 3.8
- build = "cp38-*"
+ CIBW_BUILD: cp38-*
# Skip building on CPython 3.8 on the Mac
- skip = "cp38-macosx_x86_64"
+ CIBW_SKIP: cp38-macosx_x86_64
# Skip building on CPython 3.8 on all platforms
- skip = "cp38-*"
+ CIBW_SKIP: cp38-*
# Skip CPython 3.8 on Windows
- skip = "cp38-win*"
+ CIBW_SKIP: cp38-win*
# Skip CPython 3.8 on 32-bit Windows
- skip = "cp38-win32"
+ CIBW_SKIP: cp38-win32
# Skip CPython 3.8 and CPython 3.9
- skip = ["cp38-*", "cp39-*"]
+ CIBW_SKIP: cp38-* cp39-*
# Skip Python 3.8 on Linux
- skip = "cp38-manylinux*"
+ CIBW_SKIP: cp38-manylinux*
# Skip 32-bit builds
- skip = ["*-win32", "*-manylinux_i686"]
+ CIBW_SKIP: "*-win32 *-manylinux_i686"
# Disable building PyPy wheels on all platforms
- skip = "pp*"
+ CIBW_SKIP: pp*
```
+ Separate multiple selectors with a space.
+
+
+
It is generally recommended to set `CIBW_BUILD` as an environment variable, though `skip`
tends to be useful in a config file; you can statically declare that you don't
- support PyPy, for example.
+ support a specific build, for example.
-### `CIBW_ARCHS` {: #archs}
+### `archs` {: #archs cmd-line env-var toml }
> Change the architectures built on your machine by default.
A list of architectures to build.
@@ -188,10 +190,10 @@ Options:
- `auto32`: Just the 32-bit auto archs
- `native`: the native arch of the build machine - Matches [`platform.machine()`](https://docs.python.org/3/library/platform.html#platform.machine).
- `all` : expands to all the architectures supported on this OS. You may want
- to use [CIBW_BUILD](#build-skip) with this option to target specific
+ to use [`build`](#build-skip) with this option to target specific
architectures via build selectors.
-Linux riscv64 platform support is experimental and requires an explicit opt-in through [CIBW_ENABLE](#enable).
+Linux riscv64 platform support is experimental and requires an explicit opt-in through [`enable`](#enable).
Default: `auto`
@@ -203,7 +205,7 @@ Default: `auto`
| macOS / Intel | `x86_64` | `x86_64` | `x86_64` | |
| macOS / Apple Silicon | `arm64` | `arm64` | `arm64` | |
| iOS on macOS / Intel | `x86_64_iphonesimulator` | `x86_64_iphonesimulator` | `x86_64_iphonesimulator` | |
-| iOS on macOS / Apple Silicon | `arm64_iphonesimulator` | `arm64_iphoneos` `arm64_iphonesimulator` | `arm64_iphoneos` `arm64_iphonesimulator` | |
+| iOS on macOS / Apple Silicon | `arm64_iphonesimulator` | `arm64_iphoneos` `arm64_iphonesimulator` | `arm64_iphoneos` `arm64_iphonesimulator` |
If not listed above, `auto` is the same as `native`.
@@ -218,40 +220,42 @@ This option can also be set using the [command-line option](#command-line)
#### Examples
-!!! tab examples "Environment variables"
+!!! tab examples "pyproject.toml"
- ```yaml
+ ```toml
# Build `universal2` and `arm64` wheels on an Intel runner.
# Note that the `arm64` wheel and the `arm64` part of the `universal2`
# wheel cannot be tested in this configuration.
- CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
+ [tool.cibuildwheel.macos]
+ archs = ["x86_64", "universal2", "arm64"]
# On an Linux Intel runner with qemu installed, build Intel and ARM wheels
- CIBW_ARCHS_LINUX: "auto aarch64"
+ [tool.cibuildwheel.linux]
+ archs = ["auto", "aarch64"]
```
- Separate multiple archs with a space.
-
-!!! tab examples "pyproject.toml"
+!!! tab examples "Environment variables"
- ```toml
+ ```yaml
# Build `universal2` and `arm64` wheels on an Intel runner.
# Note that the `arm64` wheel and the `arm64` part of the `universal2`
# wheel cannot be tested in this configuration.
- [tool.cibuildwheel.macos]
- archs = ["x86_64", "universal2", "arm64"]
+ CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
# On an Linux Intel runner with qemu installed, build Intel and ARM wheels
- [tool.cibuildwheel.linux]
- archs = ["auto", "aarch64"]
+ CIBW_ARCHS_LINUX: "auto aarch64"
```
+ Separate multiple archs with a space.
+
+
+
It is generally recommended to use the environment variable or
command-line option for Linux, as selecting archs often depends
on your specific runner having qemu installed.
-### `CIBW_PROJECT_REQUIRES_PYTHON` {: #requires-python}
+### `project-requires-python` {: #requires-python env-var}
> Manually set the Python compatibility of your project
By default, cibuildwheel reads your package's Python compatibility from
@@ -301,7 +305,7 @@ the package is compatible with all versions of Python that it can build.
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
```
-### `CIBW_ENABLE` {: #enable}
+### `enable` {: #enable toml env-var}
> Enable building with extra categories of selectors present.
This option lets you opt-in to non-default builds, like pre-releases and
@@ -343,16 +347,34 @@ This option doesn't support overrides or platform specific variants; it is
intended as a way to acknowledge that a project is aware that these extra
selectors exist. If you need to enable/disable it per platform or python
version, set this option to `true` and use
-[`CIBW_BUILD`](#build-skip)/[`CIBW_SKIP`](#build-skip) options to filter the
+[`build`](#build-skip)/[`skip`](#build-skip) options to filter the
builds.
Unlike all other cibuildwheel options, the environment variable setting will
only add to the TOML config; you can't remove an enable by setting an empty or
-partial list in environment variables; use `CIBW_SKIP` instead.
+partial list in environment variables; use `CIBW_SKIP` instead. This way, if
+you apply `cpython-prerelease` during the beta period using `CIBW_ENABLE`
+without disabling your other enables.
#### Examples
+!!! tab examples "pyproject.toml"
+
+ ```toml
+ [tool.cibuildwheel]
+ # Enable free-threaded support
+ enable = ["cpython-freethreading"]
+
+ # Skip building free-threaded compatible wheels on Windows
+ enable = ["cpython-freethreading"]
+ skip = "*t-win*"
+
+ # Include all PyPy versions
+ enable = ["pypy", "pypy-eol"]
+ ```
+
+
!!! tab examples "Environment variables"
```yaml
@@ -368,28 +390,14 @@ partial list in environment variables; use `CIBW_SKIP` instead.
# Skip building free-threaded compatible wheels on Windows
CIBW_ENABLE: cpython-freethreading
CIBW_SKIP: *t-win*
- ```
-
- It is generally recommended to use `cpython-freethreading` in a config
- file as you can statically declare that you support free-threaded builds.
-
-!!! tab examples "pyproject.toml"
- ```toml
- [tool.cibuildwheel]
- # Enable free-threaded support
- enable = ["cpython-freethreading"]
-
- # Skip building free-threaded compatible wheels on Windows
- enable = ["cpython-freethreading"]
- skip = "*t-win*"
+ # Include all PyPy versions
+ CIBW_ENABLE = pypy pypy-eol
```
- It is generally not recommended to use `cpython-prerelease` in a config file,
- as it's intended for testing pre-releases for a 2-3 month period only.
-### `CIBW_ALLOW_EMPTY` {: #allow-empty}
+### `allow-empty` {: #allow-empty cmd-line env-var}
> Suppress the error code if no wheels match the specified build identifiers
When none of the specified build identifiers match any available versions,
@@ -413,7 +421,7 @@ This option can also be set using the [command-line option](#command-line)
## Build customization
-### `CIBW_BUILD_FRONTEND` {: #build-frontend}
+### `build-frontend` {: #build-frontend cmd-line toml env-var}
> Set the tool to use to build, either "build" (default), "build\[uv\]", or "pip"
Options:
@@ -452,46 +460,48 @@ optional `args` option.
#### Examples
-!!! tab examples "Environment variables"
+!!! tab examples "pyproject.toml"
- ```yaml
+ ```toml
+ [tool.cibuildwheel]
# Switch to using build
- CIBW_BUILD_FRONTEND: "build"
+ build-frontend = "build"
# Ensure pip is used even if the default changes in the future
- CIBW_BUILD_FRONTEND: "pip"
+ build-frontend = "pip"
# supply an extra argument to 'pip wheel'
- CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
+ build-frontend = { name = "pip", args = ["--no-build-isolation"] }
# Use uv and build
- CIBW_BUILD_FRONTEND: "build[uv]"
+ build-frontend = "build[uv]"
# Use uv and build with an argument
- CIBW_BUILD_FRONTEND: "build[uv]; args: --no-isolation"
+ build-frontend = { name = "build[uv]", args = ["--no-isolation"] }
```
-!!! tab examples "pyproject.toml"
+!!! tab examples "Environment variables"
- ```toml
- [tool.cibuildwheel]
+ ```yaml
# Switch to using build
- build-frontend = "build"
+ CIBW_BUILD_FRONTEND: "build"
# Ensure pip is used even if the default changes in the future
- build-frontend = "pip"
+ CIBW_BUILD_FRONTEND: "pip"
# supply an extra argument to 'pip wheel'
- build-frontend = { name = "pip", args = ["--no-build-isolation"] }
+ CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
# Use uv and build
- build-frontend = "build[uv]"
+ CIBW_BUILD_FRONTEND: "build[uv]"
# Use uv and build with an argument
- build-frontend = { name = "build[uv]", args = ["--no-isolation"] }
+ CIBW_BUILD_FRONTEND: "build[uv]; args: --no-isolation"
```
-### `CIBW_CONFIG_SETTINGS` {: #config-settings}
+
+
+### `config-settings` {: #config-settings env-var toml}
> Specify config-settings for the build backend.
Specify config settings for the build backend. Each space separated
@@ -508,21 +518,23 @@ Platform-specific environment variables also available:
#### Examples
+!!! tab examples "pyproject.toml"
+
+ ```toml
+ [tool.cibuildwheel.config-settings]
+ --build-option = "--use-mypyc"
+ ```
+
!!! tab examples "Environment variables"
```yaml
CIBW_CONFIG_SETTINGS: "--build-option=--use-mypyc"
```
-!!! tab examples "pyproject.toml"
- ```toml
- [tool.cibuildwheel.config-settings]
- --build-option = "--use-mypyc"
- ```
-### `CIBW_ENVIRONMENT` {: #environment}
+### `environment` {: #environment env-var toml}
> Set environment variables
A list of environment variables to set during the build and test phases. Bash syntax should be used, even on Windows.
@@ -538,35 +550,6 @@ Platform-specific environment variables are also available:
#### Examples
-!!! tab examples "Environment variables"
-
- ```yaml
- # Set some compiler flags
- CIBW_ENVIRONMENT: CFLAGS='-g -Wall' CXXFLAGS='-Wall'
-
- # Append a directory to the PATH variable (this is expanded in the build environment)
- CIBW_ENVIRONMENT: PATH=$PATH:/usr/local/bin
-
- # Prepend a directory containing spaces on Windows.
- CIBW_ENVIRONMENT_WINDOWS: >
- PATH="C:\\Program Files\\PostgreSQL\\13\\bin;$PATH"
-
- # Set BUILD_TIME to the output of the `date` command
- CIBW_ENVIRONMENT: BUILD_TIME="$(date)"
-
- # Supply options to `pip` to affect how it downloads dependencies
- CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.myorg.com/simple
-
- # Any pip command-line options can be set using the PIP_ prefix
- # https://pip.pypa.io/en/stable/topics/configuration/#environment-variables
- CIBW_ENVIRONMENT: PIP_GLOBAL_OPTION="build_ext -j4"
-
- # Set two flags on linux only
- CIBW_ENVIRONMENT_LINUX: BUILD_TIME="$(date)" SAMPLE_TEXT="sample text"
- ```
-
- Separate multiple values with a space.
-
!!! tab examples "pyproject.toml"
```toml
@@ -604,7 +587,36 @@ Platform-specific environment variables are also available:
SAMPLE_TEXT = "sample text"
```
- In configuration mode, you can use a [TOML][] table instead of a raw string as shown above.
+ In configuration files, you can use a [TOML][] table instead of a raw string as shown above.
+
+!!! tab examples "Environment variables"
+
+ ```yaml
+ # Set some compiler flags
+ CIBW_ENVIRONMENT: CFLAGS='-g -Wall' CXXFLAGS='-Wall'
+
+ # Append a directory to the PATH variable (this is expanded in the build environment)
+ CIBW_ENVIRONMENT: PATH=$PATH:/usr/local/bin
+
+ # Prepend a directory containing spaces on Windows.
+ CIBW_ENVIRONMENT_WINDOWS: >
+ PATH="C:\\Program Files\\PostgreSQL\\13\\bin;$PATH"
+
+ # Set BUILD_TIME to the output of the `date` command
+ CIBW_ENVIRONMENT: BUILD_TIME="$(date)"
+
+ # Supply options to `pip` to affect how it downloads dependencies
+ CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.myorg.com/simple
+
+ # Any pip command-line options can be set using the PIP_ prefix
+ # https://pip.pypa.io/en/stable/topics/configuration/#environment-variables
+ CIBW_ENVIRONMENT: PIP_GLOBAL_OPTION="build_ext -j4"
+
+ # Set two flags on linux only
+ CIBW_ENVIRONMENT_LINUX: BUILD_TIME="$(date)" SAMPLE_TEXT="sample text"
+ ```
+
+ Separate multiple values with a space.
!!! note
cibuildwheel always defines the environment variable `CIBUILDWHEEL=1`. This can be useful for [building wheels with optional extensions](faq.md#optional-extensions).
@@ -612,7 +624,7 @@ Platform-specific environment variables are also available:
!!! note
To do its work, cibuildwheel sets the variables `VIRTUALENV_PIP`, `DIST_EXTRA_CONFIG`, `SETUPTOOLS_EXT_SUFFIX`, `PIP_DISABLE_PIP_VERSION_CHECK`, `PIP_ROOT_USER_ACTION`, and it extends the variables `PATH` and `PIP_CONSTRAINT`. Your assignments to these options might be replaced or extended.
-### `CIBW_ENVIRONMENT_PASS_LINUX` {: #environment-pass}
+### `environment-pass` {: #environment-pass env-var="CIBW_ENVIRONMENT_PASS_LINUX" toml}
> Set environment variables on the host to pass-through to the container.
A list of environment variables to pass into the linux container during each build and test. It has no effect on the other platforms, which can already access all environment variables directly.
@@ -624,33 +636,33 @@ To specify more than one environment variable, separate the variable names by sp
#### Examples
-!!! tab examples "Environment passthrough"
+!!! tab examples "pyproject.toml"
+
+ ```toml
+ [tool.cibuildwheel.linux]
- ```yaml
# Export a variable
- CIBW_ENVIRONMENT_PASS_LINUX: CFLAGS
+ environment-pass = ["CFLAGS"]
# Set two flags variables
- CIBW_ENVIRONMENT_PASS_LINUX: BUILD_TIME SAMPLE_TEXT
+ environment-pass = ["BUILD_TIME", "SAMPLE_TEXT"]
```
- Separate multiple values with a space.
-
-!!! tab examples "pyproject.toml"
+ In configuration files, you can use a [TOML][] list instead of a raw string as shown above.
- ```toml
- [tool.cibuildwheel.linux]
+!!! tab examples "Environment variables"
+ ```yaml
# Export a variable
- environment-pass = ["CFLAGS"]
+ CIBW_ENVIRONMENT_PASS_LINUX: CFLAGS
# Set two flags variables
- environment-pass = ["BUILD_TIME", "SAMPLE_TEXT"]
+ CIBW_ENVIRONMENT_PASS_LINUX: BUILD_TIME SAMPLE_TEXT
```
- In configuration mode, you can use a [TOML][] list instead of a raw string as shown above.
+ Separate multiple values with a space.
-### `CIBW_BEFORE_ALL` {: #before-all}
+### `before-all` {: #before-all env-var toml}
> Execute a shell command on the build system before any wheels are built.
Shell command that runs before any builds are run, to build or install parts that do not depend on the specific version of Python.
@@ -659,7 +671,7 @@ This option is very useful for the Linux build, where builds take place in isola
The placeholder `{package}` can be used here; it will be replaced by the path to the package being built by cibuildwheel.
-On Windows and macOS, the version of Python available inside `CIBW_BEFORE_ALL` is whatever is available on the host machine. On Linux, a modern Python version is available on PATH.
+On Windows and macOS, the version of Python available inside `before-all` is whatever is available on the host machine. On Linux, a modern Python version is available on PATH.
This option has special behavior in the overrides section in `pyproject.toml`.
On linux, overriding it triggers a new container launch. It cannot be overridden
@@ -670,30 +682,10 @@ Platform-specific environment variables also available:
!!! note
- This command is executed in a different Python environment from the builds themselves. So you can't `pip install` a Python dependency in CIBW_BEFORE_ALL and use it in the build. Instead, look at [`CIBW_BEFORE_BUILD`](#before-build), or, if your project uses pyproject.toml, the [build-system.requires](https://peps.python.org/pep-0518/#build-system-table) field.
+ This command is executed in a different Python environment from the builds themselves. So you can't `pip install` a Python dependency in `before-all` and use it in the build. Instead, look at [`before-build`](#before-build), or, if your project uses pyproject.toml, the [build-system.requires](https://peps.python.org/pep-0518/#build-system-table) field.
#### Examples
-!!! tab examples "Environment variables"
-
- ```yaml
- # Build third party library
- CIBW_BEFORE_ALL: make -C third_party_lib
-
- # Install system library
- CIBW_BEFORE_ALL_LINUX: yum install -y libffi-devel
-
- # Chain multiple commands using && and > in a YAML file, like:
- CIBW_BEFORE_ALL: >
- yum install bzip2 -y &&
- make third_party
- ```
-
- For multiline commands, see the last example. The character `>` means that
- whitespace is collapsed to a single line, and '&&' between each command
- ensures that errors are not ignored. [Further reading on multiline YAML
- here.](https://yaml-multiline.info).
-
!!! tab examples "pyproject.toml"
```toml
@@ -714,41 +706,47 @@ Platform-specific environment variables also available:
In configuration files, you can use a TOML array, and each line will be run sequentially - joined with `&&`.
-Note that manylinux_2_31 builds occur inside a debian derivative docker container, where
-manylinux2014 builds occur inside a CentOS one. So for `manylinux_2_31` the `CIBW_BEFORE_ALL_LINUX` command
-must use `apt-get -y` instead.
+!!! tab examples "Environment variables"
-### `CIBW_BEFORE_BUILD` {: #before-build}
-> Execute a shell command preparing each wheel's build
+ ```yaml
+ # Build third party library
+ CIBW_BEFORE_ALL: make -C third_party_lib
-A shell command to run before building the wheel. This option allows you to run a command in **each** Python environment before the `pip wheel` command. This is useful if you need to set up some dependency so it's available during the build.
+ # Install system library
+ CIBW_BEFORE_ALL_LINUX: yum install -y libffi-devel
-If dependencies are required to build your wheel (for example if you include a header from a Python module), instead of using this command, we recommend adding requirements to a `pyproject.toml` file's `build-system.requires` array instead. This is reproducible, and users who do not get your wheels (such as Alpine or ClearLinux users) will still benefit.
+ # Chain multiple commands using && and > in a YAML file, like:
+ CIBW_BEFORE_ALL: >
+ yum install bzip2 -y &&
+ make third_party
+ ```
-The active Python binary can be accessed using `python`, and pip with `pip`; cibuildwheel makes sure the right version of Python and pip will be executed. The placeholder `{package}` can be used here; it will be replaced by the path to the package being built by cibuildwheel.
+ For multiline commands, see the last example. The character `>` means that
+ whitespace is collapsed to a single line, and '&&' between each command
+ ensures that errors are not ignored. [Further reading on multiline YAML
+ here.](https://yaml-multiline.info).
-The command is run in a shell, so you can write things like `cmd1 && cmd2`.
-Platform-specific environment variables are also available:
- `CIBW_BEFORE_BUILD_MACOS` | `CIBW_BEFORE_BUILD_WINDOWS` | `CIBW_BEFORE_BUILD_LINUX` | `CIBW_BEFORE_BUILD_IOS` | `CIBW_BEFORE_BUILD_PYODIDE`
+Note that `manylinux_2_31` builds occur inside a Debian derivative docker
+container, where `manylinux2014` builds occur inside a CentOS one. So for
+`manylinux_2_31` the `before-all` command must use `apt-get -y`
+instead.
-#### Examples
+### `before-build` {: #before-build env-var toml}
+> Execute a shell command preparing each wheel's build
-!!! tab examples "Environment variables"
+A shell command to run before building the wheel. This option allows you to run a command in **each** Python environment before the `pip wheel` command. This is useful if you need to set up some dependency so it's available during the build.
- ```yaml
- # Install something required for the build (you might want to use pyproject.toml instead)
- CIBW_BEFORE_BUILD: pip install pybind11
+If dependencies are required to build your wheel (for example if you include a header from a Python module), instead of using this command, we recommend adding requirements to a `pyproject.toml` file's `build-system.requires` array instead. This is reproducible, and users who do not get your wheels (such as Alpine or ClearLinux users) will still benefit.
- # Chain commands using &&
- CIBW_BEFORE_BUILD_LINUX: python scripts/install-deps.py && make clean
+The active Python binary can be accessed using `python`, and pip with `pip`; cibuildwheel makes sure the right version of Python and pip will be executed. The placeholder `{package}` can be used here; it will be replaced by the path to the package being built by cibuildwheel.
- # Run a script that's inside your project
- CIBW_BEFORE_BUILD: bash scripts/prepare_for_build.sh
+The command is run in a shell, so you can write things like `cmd1 && cmd2`.
- # If cibuildwheel is called with a package_dir argument, it's available as {package}
- CIBW_BEFORE_BUILD: "{package}/script/prepare_for_build.sh"
- ```
+Platform-specific environment variables are also available:
+ `CIBW_BEFORE_BUILD_MACOS` | `CIBW_BEFORE_BUILD_WINDOWS` | `CIBW_BEFORE_BUILD_LINUX` | `CIBW_BEFORE_BUILD_IOS` | `CIBW_BEFORE_BUILD_PYODIDE`
+
+#### Examples
!!! tab examples "pyproject.toml"
@@ -773,9 +771,27 @@ Platform-specific environment variables are also available:
before-build = "{package}/script/prepare_for_build.sh"
```
- In configuration mode, you can use a array, and the items will be joined with `&&`. In TOML, using a single-quote string will avoid escapes - useful for
+ In configuration files, you can use a array, and the items will be joined
+ with `&&`. In TOML, using a single-quote string will avoid escapes - useful for
Windows paths.
+!!! tab examples "Environment variables"
+
+ ```yaml
+ # Install something required for the build (you might want to use pyproject.toml instead)
+ CIBW_BEFORE_BUILD: pip install pybind11
+
+ # Chain commands using &&
+ CIBW_BEFORE_BUILD_LINUX: python scripts/install-deps.py && make clean
+
+ # Run a script that's inside your project
+ CIBW_BEFORE_BUILD: bash scripts/prepare_for_build.sh
+
+ # If cibuildwheel is called with a package_dir argument, it's available as {package}
+ CIBW_BEFORE_BUILD: "{package}/script/prepare_for_build.sh"
+ ```
+
+
!!! note
If you need Python dependencies installed for the build, we recommend using
`pyproject.toml`'s `build-system.requires` instead. This is an example
@@ -785,8 +801,7 @@ Platform-specific environment variables are also available:
requires = [
"setuptools>=42",
"Cython",
- "numpy==1.13.3; python_version<'3.5'",
- "oldest-supported-numpy; python_version>='3.5'",
+ "numpy",
]
build-backend = "setuptools.build_meta"
@@ -794,59 +809,53 @@ Platform-specific environment variables are also available:
This [PEP 517][]/[PEP 518][] style build allows you to completely control
the build environment in cibuildwheel, [PyPA-build][], and pip, doesn't
force downstream users to install anything they don't need, and lets you do
- more complex pinning (Cython, for example, requires a wheel to be built
- with an equal or earlier version of NumPy; pinning in this way is the only
- way to ensure your module works on all available NumPy versions).
+ more complex pinning.
[PyPA-build]: https://pypa-build.readthedocs.io/en/latest/
[PEP 517]: https://www.python.org/dev/peps/pep-0517/
[PEP 518]: https://www.python.org/dev/peps/pep-0517/
-### `CIBW_XBUILD_TOOLS` {: #xbuild-tools}
+### `xbuild-tools` {: #xbuild-tools env-var toml}
> Binaries on the path that should be included in an isolated cross-build environment.
When building in a cross-platform environment, it is sometimes necessary to isolate the ``PATH`` so that binaries from the build machine don't accidentally get linked into the cross-platform binary. However, this isolation process will also hide tools that might be required to build your wheel.
-If there are binaries present on the `PATH` when you invoke cibuildwheel, and those binaries are required to build your wheels, those binaries can be explicitly included in the isolated cross-build environment using `CIBW_XBUILD_TOOLS`. The binaries listed in this setting will be linked into an isolated location, and that isolated location will be put on the `PATH` of the isolated environment. You do not need to provide the full path to the binary - only the executable name that would be found by the shell.
+If there are binaries present on the `PATH` when you invoke cibuildwheel, and those binaries are required to build your wheels, those binaries can be explicitly included in the isolated cross-build environment using `xbuild-tools`. The binaries listed in this setting will be linked into an isolated location, and that isolated location will be put on the `PATH` of the isolated environment. You do not need to provide the full path to the binary - only the executable name that would be found by the shell.
If you declare a tool as a cross-build tool, and that tool cannot be found in the runtime environment, an error will be raised.
-If you do not define `CIBW_XBUILD_TOOLS`, and you build for a platform that uses a cross-platform environment, a warning will be raised. If your project does not require any cross-build tools, you can set `CIBW_XBUILD_TOOLS` to an empty list to silence this warning.
+If you do not define `xbuild-tools`, and you build for a platform that uses a cross-platform environment, a warning will be raised. If your project does not require any cross-build tools, you can set `xbuild-tools` to an empty list to silence this warning.
-*Any* tool used by the build process must be included in the `CIBW_XBUILD_TOOLS` list, not just tools that cibuildwheel will invoke directly. For example, if your build invokes `cmake`, and the `cmake` script invokes `magick` to perform some image transformations, both `cmake` and `magick` must be included in your safe tools list.
+*Any* tool used by the build process must be included in the `xbuild-tools` list, not just tools that cibuildwheel will invoke directly. For example, if your build invokes `cmake`, and the `cmake` script invokes `magick` to perform some image transformations, both `cmake` and `magick` must be included in your safe tools list.
Platform-specific environment variables are also available on platforms that use cross-platform environment isolation:
`CIBW_XBUILD_TOOLS_IOS`
#### Examples
-!!! tab examples "Environment variables"
+!!! tab examples "pyproject.toml"
- ```yaml
+ ```toml
+ [tool.cibuildwheel]
# Allow access to the cmake and rustc binaries in the isolated cross-build environment.
- CIBW_XBUILD_TOOLS: cmake rustc
- ```
+ xbuild-tools = ["cmake", "rustc"]
- ```yaml
# No cross-build tools are required
- CIBW_XBUILD_TOOLS:
+ xbuild-tools = []
```
-!!! tab examples "pyproject.toml"
+!!! tab examples "Environment variables"
- ```toml
- [tool.cibuildwheel]
+ ```yaml
# Allow access to the cmake and rustc binaries in the isolated cross-build environment.
- xbuild-tools = ["cmake", "rustc"]
- ```
+ CIBW_XBUILD_TOOLS: cmake rustc
- ```toml
- [tool.cibuildwheel]
# No cross-build tools are required
- xbuild-tools = []
+ CIBW_XBUILD_TOOLS:
```
-### `CIBW_REPAIR_WHEEL_COMMAND` {: #repair-wheel-command}
+
+### `repair-wheel-command` {: #repair-wheel-command env-var toml}
> Execute a shell command to repair each built wheel
Default:
@@ -888,36 +897,6 @@ Platform-specific environment variables are also available:
#### Examples
-!!! tab examples "Environment variables"
-
- ```yaml
- # Use delvewheel on windows
- CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
- CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
-
- # Don't repair macOS wheels
- CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
-
- # Pass the `--lib-sdir .` flag to auditwheel on Linux
- CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --lib-sdir . -w {dest_dir} {wheel}"
-
- # Multi-line example - use && to join on all platforms
- CIBW_REPAIR_WHEEL_COMMAND: >
- python scripts/repair_wheel.py -w {dest_dir} {wheel} &&
- python scripts/check_repaired_wheel.py -w {dest_dir} {wheel}
-
- # Use abi3audit to catch issues with Limited API wheels
- CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
- auditwheel repair -w {dest_dir} {wheel} &&
- pipx run abi3audit --strict --report {wheel}
- CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
- delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
- pipx run abi3audit --strict --report {wheel}
- CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
- copy {wheel} {dest_dir} &&
- pipx run abi3audit --strict --report {wheel}
- ```
-
!!! tab examples "pyproject.toml"
```toml
@@ -959,45 +938,76 @@ Platform-specific environment variables are also available:
]
```
- In configuration mode, you can use an inline array, and the items will be joined with `&&`.
+ In configuration files, you can use an inline array, and the items will be joined with `&&`.
+
+
+!!! tab examples "Environment variables"
+
+ ```yaml
+ # Use delvewheel on windows
+ CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
+ CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
+
+ # Don't repair macOS wheels
+ CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
+
+ # Pass the `--lib-sdir .` flag to auditwheel on Linux
+ CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --lib-sdir . -w {dest_dir} {wheel}"
+
+ # Multi-line example - use && to join on all platforms
+ CIBW_REPAIR_WHEEL_COMMAND: >
+ python scripts/repair_wheel.py -w {dest_dir} {wheel} &&
+ python scripts/check_repaired_wheel.py -w {dest_dir} {wheel}
+
+ # Use abi3audit to catch issues with Limited API wheels
+ CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
+ auditwheel repair -w {dest_dir} {wheel} &&
+ pipx run abi3audit --strict --report {wheel}
+ CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
+ delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
+ pipx run abi3audit --strict --report {wheel}
+ CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
+ copy {wheel} {dest_dir} &&
+ pipx run abi3audit --strict --report {wheel}
+ ```
'+envVar+'
');
+ }
+ if (toml) {
+ $(el).append(' '+toml+'
');
+ }
+ if (cmdLine) {
+ $(el).append(' '+cmdLine+'
');
+ }
+ });
});
+