2019-10-20 20:39:50 +01:00
## Options summary
<div class="options-toc"></div>
## Setting options
2019-10-06 20:36:21 +01:00
2019-11-12 23:34:59 +00:00
cibuildwheel is configured using environment variables, that can be set using
2019-10-02 09:49:31 +01:00
your CI config.
2019-09-29 21:53:18 +01:00
2019-10-06 20:36:21 +01:00
For example, to configure cibuildwheel to run tests, add the following YAML to
your CI config file:
> .travis.yml ([docs](https://docs.travis-ci.com/user/environment-variables/))
```yaml
env :
2019-10-02 09:49:31 +01:00
global :
2020-03-31 15:14:27 -04:00
- CIBW_TEST_REQUIRES=pytest
- CIBW_TEST_COMMAND="pytest {project}/tests"
2019-10-06 20:36:21 +01:00
```
> appveyor.yml ([docs](https://www.appveyor.com/docs/build-configuration/#environment-variables))
```yaml
environment :
2019-10-02 09:49:31 +01:00
global :
2020-03-31 15:14:27 -04:00
CIBW_TEST_REQUIRES : pytest
CIBW_TEST_COMMAND : "pytest {project}\\tests"
2019-10-06 20:36:21 +01:00
```
> .circleci/config.yml ([docs](https://circleci.com/docs/2.0/configuration-reference/#environment))
```yaml
jobs :
2019-10-02 09:49:31 +01:00
job_name :
environment :
2020-03-31 15:14:27 -04:00
CIBW_TEST_REQUIRES : pytest
CIBW_TEST_COMMAND : "pytest {project}/tests"
2019-10-06 20:36:21 +01:00
```
> azure-pipelines.yml ([docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables))
```yaml
variables :
2020-03-31 15:14:27 -04:00
CIBW_TEST_REQUIRES : pytest
CIBW_TEST_COMMAND : "pytest {project}/tests"
2019-10-06 20:36:21 +01:00
```
2019-09-29 21:53:18 +01:00
2020-03-31 14:51:32 -04:00
> .github/workflows/*.yml ([docs](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables)) (can be global, in job, or in step)
```yaml
env :
2020-03-31 15:14:27 -04:00
CIBW_TEST_REQUIRES : pytest
CIBW_TEST_COMMAND : "pytest {project}/tests"
2019-10-06 20:36:21 +01:00
```
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
2019-10-20 20:39:50 +01:00
## Build selection
2019-09-29 21:53:18 +01:00
2019-11-09 19:38:59 +00:00
### `CIBW_PLATFORM` {: #platform}
2019-11-10 14:54:56 +00:00
2019-10-20 20:39:50 +01:00
> Override the auto-detected target platform
2019-09-29 21:53:18 +01:00
Options: `auto` `linux` `macos` `windows`
Default: `auto`
`auto` will auto-detect platform using environment variables, such as `TRAVIS_OS_NAME` /`APPVEYOR` /`CIRCLECI` .
2020-02-11 14:44:53 +01:00
For `linux` you need Docker running, on macOS or Linux. For `macos` , you need a Mac machine, and note that this script is going to automatically install MacPython on your system, so don't run on your development machine. For `windows` , you need to run in Windows, and `cibuildwheel` will install required versions of Python to `C:\cibw\python` using NuGet.
2019-09-29 21:53:18 +01:00
2019-11-10 14:57:21 +00:00
This option can also be set using the command-line option `--platform` .
2019-11-10 14:54:56 +00:00
2020-05-17 22:26:12 +02:00
2019-11-09 19:38:59 +00:00
### `CIBW_BUILD`, `CIBW_SKIP` {: #build-skip}
2019-11-03 18:35:06 +00:00
2019-10-20 20:39:50 +01:00
> Choose the Python versions to build
2019-09-29 21:53:18 +01:00
2019-11-19 23:36:20 +01:00
Space-separated list of builds to build and skip. Each build has an identifier like `cp27-manylinux_x86_64` or `cp35-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.
2019-09-29 21:53:18 +01:00
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.
2019-12-26 13:51:57 +01:00
When setting the options, you can use shell-style globbing syntax (as per [`fnmatch` ](https://docs.python.org/3/library/fnmatch.html )). All the build identifiers supported by cibuildwheel are shown below:
2019-09-29 21:53:18 +01:00
2019-11-10 13:21:05 +00:00
<div class="build-id-table-marker"></div>
2019-09-29 21:53:18 +01:00
2020-02-20 13:51:37 -05:00
| | macOS 64bit | Manylinux x86 64bit | Manylinux x86 32bit | Windows 64bit | Windows 32bit | Manylinux Armv8 64bit | Manylinux PPC64LE | Manylinux s390x |
|-----------------|---------------------|------------------------|----------------------|-----------------|----------------|------------------------|------------------------|----------------------|
| Python 2.7 | cp27-macosx_x86_64 | cp27-manylinux_x86_64 | cp27-manylinux_i686 | cp27-win_amd64 | cp27-win32 | | | |
| Python 3.5 | cp35-macosx_x86_64 | cp35-manylinux_x86_64 | cp35-manylinux_i686 | cp35-win_amd64 | cp35-win32 | cp35-manylinux_aarch64 | cp35-manylinux_ppc64le | cp35-manylinux_s390x |
| Python 3.6 | cp36-macosx_x86_64 | cp36-manylinux_x86_64 | cp36-manylinux_i686 | cp36-win_amd64 | cp36-win32 | cp36-manylinux_aarch64 | cp36-manylinux_ppc64le | cp36-manylinux_s390x |
| Python 3.7 | cp37-macosx_x86_64 | cp37-manylinux_x86_64 | cp37-manylinux_i686 | cp37-win_amd64 | cp37-win32 | cp37-manylinux_aarch64 | cp37-manylinux_ppc64le | cp37-manylinux_s390x |
| Python 3.8 | cp38-macosx_x86_64 | cp38-manylinux_x86_64 | cp38-manylinux_i686 | cp38-win_amd64 | cp38-win32 | cp38-manylinux_aarch64 | cp38-manylinux_ppc64le | cp38-manylinux_s390x |
2020-10-08 08:54:58 +01:00
| Python 3.9 | cp39-macosx_x86_64 | cp39-manylinux_x86_64 | cp39-manylinux_i686 | cp39-win_amd64 | cp39-win32 | cp39-manylinux_aarch64 | cp39-manylinux_ppc64le | cp39-manylinux_s390x |
2020-11-22 14:55:04 +01:00
| PyPy 2.7 v7.3.3 | pp27-macosx_x86_64 | pp27-manylinux_x86_64 | | | pp27-win32 | | | |
| PyPy 3.6 v7.3.3 | pp36-macosx_x86_64 | pp36-manylinux_x86_64 | | | pp36-win32 | | | |
| PyPy 3.7 (beta) v7.3.3 | pp37-macosx_x86_64 | pp37-manylinux_x86_64 | | | pp37-win32 | | | |
2020-09-10 15:31:12 +02:00
2019-09-29 21:53:18 +01:00
2019-11-10 13:21:05 +00:00
The list of supported and currently selected build identifiers can also be retrieved by passing the `--print-build-identifiers` flag to `cibuildwheel` .
The format is `python_tag-platform_tag` , with tags similar to those in [PEP 425 ](https://www.python.org/dev/peps/pep-0425/#details ).
2019-11-03 19:38:18 +00:00
2020-09-10 15:31:12 +02:00
For CPython, the minimally supported macOS version is 10.9; for PyPy 2.7 and PyPy 3.6/3.7, respectively macOS 10.7 and 10.13 or higher is required.
2020-02-11 14:44:53 +01:00
2019-11-10 13:21:05 +00:00
#### Examples
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
```yaml
# Only build on Python 3.6
CIBW_BUILD : cp36-*
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
# Skip building on Python 2.7 on the Mac
2019-11-19 23:36:20 +01:00
CIBW_SKIP : cp27-macosx_x86_64
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Skip building on Python 3.8 on the Mac
2019-12-09 00:39:29 +01:00
CIBW_SKIP : cp38-macosx_x86_64
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Skip building on Python 2.7 on all platforms
CIBW_SKIP : cp27-*
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Skip Python 2.7 on Windows
CIBW_SKIP : cp27-win*
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Skip Python 2.7 on 32-bit Windows
CIBW_SKIP : cp27-win32
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Skip Python 2.7 and Python 3.5
CIBW_SKIP : cp27-* cp35-*
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Skip Python 3.6 on Linux
CIBW_SKIP : cp36-manylinux*
2019-11-10 13:21:05 +00:00
2019-11-10 14:54:56 +00:00
# Only build on Python 3 and skip 32-bit builds
CIBW_BUILD : cp3?-*
CIBW_SKIP : "*-win32 *-manylinux_i686"
2019-12-26 13:51:57 +01:00
# Only build PyPy and CPython 3
2020-02-13 10:52:46 +01:00
CIBW_BUILD : pp* cp3?-*
2020-02-19 17:09:18 +01:00
# Disable building PyPy wheels on all platforms
CIBW_SKIP : pp*
2019-11-10 14:54:56 +00:00
```
2019-11-10 13:21:05 +00:00
<style>
.build-id-table-marker + table {
font-size: 90%;
white-space: nowrap;
}
2019-11-12 23:34:59 +00:00
.rst-content .build-id-table-marker + table td,
2019-11-10 13:21:05 +00:00
.rst-content .build-id-table-marker + table th {
padding: 4px 4px;
}
.build-id-table-marker + table td:not(:first-child) {
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-size: 85%;
}
dt code {
font-size: 100%;
background-color: rgba(41, 128, 185, 0.1);
padding: 0;
}
</style>
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
## Build customization
2019-11-09 19:38:59 +00:00
### `CIBW_ENVIRONMENT` {: #environment}
2019-10-20 20:39:50 +01:00
> Set environment variables needed during the build
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
A space-separated list of environment variables to set during the build. Bash syntax should be used, even on Windows.
2019-09-29 21:53:18 +01:00
You must set this variable to pass variables to Linux builds (since they execute in a Docker container). It also works for the other platforms.
You can use `$PATH` syntax to insert other variables, or the `$(pwd)` syntax to insert the output of other shell commands.
2020-03-07 18:05:30 +00:00
To specify more than one environment variable, separate the assignments by spaces.
2019-12-01 18:38:26 +01:00
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
`CIBW_ENVIRONMENT_MACOS` | `CIBW_ENVIRONMENT_WINDOWS` | `CIBW_ENVIRONMENT_LINUX`
2019-11-10 14:54:56 +00:00
#### Examples
```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"
# 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"
2019-12-01 18:38:26 +01:00
# Set two flags
CIBW_ENVIRONMENT : "BUILD_TIME=$(date) SAMPLE_TEXT=\"sample text\""
2019-11-10 14:54:56 +00:00
```
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
!!! note
`cibuildwheel` always defines the environment variable `CIBUILDWHEEL=1` . This can be useful for [building wheels with optional extensions ](faq.md#building-packages-with-optional-c-extensions ).
2019-09-29 21:53:18 +01:00
2020-05-11 17:09:54 +02:00
### `CIBW_BEFORE_ALL` {: #before-all}
2020-05-17 17:14:50 +02:00
> Execute a shell command on the build system before any wheels are built.
2020-05-11 17:09:54 +02:00
2020-06-14 10:35:54 +01:00
Shell command to prepare a common part of the project (e.g. build or install libraries which does not depend on the specific version of Python).
2020-05-17 17:14:50 +02:00
This option is very useful for the Linux build, where builds take place in isolated Docker containers managed by cibuildwheel. This command will run inside the container before the wheel builds start. Note, if you're building both x86_64 and i686 wheels (the default), your build uses two different Docker images. In that case, this command will execute twice - once per build container.
2020-05-11 17:09:54 +02:00
The placeholder `{package}` can be used here; it will be replaced by the path to the package being built by `cibuildwheel` .
2020-06-14 10:35:54 +01:00
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.
2020-05-15 13:13:13 +02:00
2020-05-11 17:09:54 +02:00
Platform-specific variants also available:<br/>
`CIBW_BEFORE_ALL_MACOS` | `CIBW_BEFORE_ALL_WINDOWS` | `CIBW_BEFORE_ALL_LINUX`
#### Examples
```yaml
# build third party library
CIBW_BEFORE_ALL : make -C third_party_lib
# install system library
2020-05-17 17:14:50 +02:00
CIBW_BEFORE_ALL_LINUX : yum install -y libffi-dev
2020-05-11 17:09:54 +02:00
```
2019-11-09 19:38:59 +00:00
### `CIBW_BEFORE_BUILD` {: #before-build}
2019-10-20 20:39:50 +01:00
> Execute a shell command preparing each wheel's build
2019-09-29 21:53:18 +01:00
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.
If dependencies are required to build your wheel (for example if you include a header from a Python module), set this to `pip install .` , and the dependencies will be installed automatically by pip. However, this means your package will be built twice - if your package takes a long time to build, you might wish to manually list the dependencies here instead.
2020-04-10 12:59:22 +01:00
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` .
2019-11-12 23:34:59 +00:00
2020-03-07 18:05:30 +00:00
The command is run in a shell, so you can write things like `cmd1 && cmd2` .
2019-09-29 21:53:18 +01:00
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
`CIBW_BEFORE_BUILD_MACOS` | `CIBW_BEFORE_BUILD_WINDOWS` | `CIBW_BEFORE_BUILD_LINUX`
2019-11-10 14:54:56 +00:00
#### Examples
```yaml
# install your project and dependencies before building
CIBW_BEFORE_BUILD : pip install .
# install something required for the build
CIBW_BEFORE_BUILD : pip install pybind11
# chain commands using &&
CIBW_BEFORE_BUILD : yum install -y libffi-dev && pip install .
2020-03-07 18:05:30 +00:00
2020-04-10 12:59:22 +01:00
# run a script that's inside your project
2020-03-07 18:05:30 +00:00
CIBW_BEFORE_BUILD : bash scripts/prepare_for_build.sh
2020-04-10 12:59:22 +01:00
# if cibuildwheel is called with a package_dir argument, it's available as {package}
CIBW_BEFORE_BUILD : "{package}/bin/prepare_for_build.sh"
2019-11-10 14:54:56 +00:00
```
2019-09-29 21:53:18 +01:00
2019-11-09 19:38:59 +00:00
2019-11-15 02:27:29 +00:00
### `CIBW_REPAIR_WHEEL_COMMAND` {: #repair-wheel-command}
2019-11-12 23:34:59 +00:00
> Execute a shell command to repair each (non-pure Python) built wheel
Default:
2019-11-15 02:27:29 +00:00
2019-11-12 23:34:59 +00:00
- on Linux: `'auditwheel repair -w {dest_dir} {wheel}'`
2019-11-19 23:36:20 +01:00
- on macOS: `'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}'`
2019-11-12 23:34:59 +00:00
- on Windows: `''`
A shell command to repair a built wheel by copying external library dependencies into the wheel tree and relinking them.
The command is run on each built wheel (except for pure Python ones) before testing it.
The following placeholders must be used inside the command and will be replaced by `cibuildwheel` :
2019-11-15 02:27:29 +00:00
2019-11-12 23:34:59 +00:00
- `{wheel}` for the absolute path to the built wheel
- `{dest_dir}` for the absolute path of the directory where to create the repaired wheel.
2020-03-07 18:05:30 +00:00
The command is run in a shell, so you can run multiple commands like `cmd1 && cmd2` .
2019-11-12 23:34:59 +00:00
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
`CIBW_REPAIR_WHEEL_COMMAND_MACOS` | `CIBW_REPAIR_WHEEL_COMMAND_WINDOWS` | `CIBW_REPAIR_WHEEL_COMMAND_LINUX`
2019-11-15 02:27:29 +00:00
#### Examples
```yaml
# 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}"
```
2019-11-12 23:34:59 +00:00
2020-02-20 13:51:37 -05:00
### `CIBW_MANYLINUX_X86_64_IMAGE`, `CIBW_MANYLINUX_I686_IMAGE`, `CIBW_MANYLINUX_PYPY_X86_64_IMAGE`, `CIBW_MANYLINUX_AARCH64_IMAGE`, `CIBW_MANYLINUX_PPC64LE_IMAGE`, `CIBW_MANYLINUX_S390X_IMAGE` {: #manylinux-image}
2019-11-12 23:34:59 +00:00
> Specify alternative manylinux docker images
2019-09-29 21:53:18 +01:00
2020-02-21 06:48:10 -05:00
An alternative Docker image to be used for building [`manylinux` ](https://github.com/pypa/manylinux ) wheels. `cibuildwheel` will then pull these instead of the default images, [`quay.io/pypa/manylinux2010_x86_64` ](https://quay.io/pypa/manylinux2010_x86_64 ), [`quay.io/pypa/manylinux2010_i686` ](https://quay.io/pypa/manylinux2010_i686 ), [`pypywheels/manylinux2010-pypy_x86_64` ](https://hub.docker.com/r/pypywheels/manylinux2010-pypy_x86_64 ), [`quay.io/pypa/manylinux2014_aarch64` ](https://quay.io/pypa/manylinux2014_aarch64 ), [`quay.io/pypa/manylinux2014_ppc64le` ](https://quay.io/pypa/manylinux2014_ppc64le ), and [`quay.io/pypa/manylinux2014_s390x` ](https://quay.io/pypa/manylinux2010_s390x ).
2019-09-29 21:53:18 +01:00
2020-03-01 12:53:07 +00:00
The value of this option can either be set to `manylinux1` , `manylinux2010` or `manylinux2014` to use a pinned version of the [official `manylinux` images ](https://github.com/pypa/manylinux ) and [PyPy `manylinux` images ](https://github.com/pypy/manylinux ). Alternatively, set these options to any other valid Docker image name. Note that for PyPy, only the official `manylinux2010` image is currently available. For architectures other
2020-02-21 06:48:10 -05:00
than x86 (x86\_64 and i686) manylinux2014 must be used because this is the first version of the manylinux specification that supports additional architectures.
2019-09-29 21:53:18 +01:00
2019-12-26 13:51:57 +01:00
Beware to specify a valid Docker image that can be used in the same way as the official, default Docker images: all necessary Python and pip versions need to be present in `/opt/python/` , and the `auditwheel` tool needs to be present for `cibuildwheel` to work. Apart from that, the architecture and relevant shared system libraries need to be manylinux1-, manylinux2010- or manylinux2014-compatible in order to produce valid `manylinux1` /`manylinux2010` /`manylinux2014` wheels (see [pypa/manylinux on GitHub ](https://github.com/pypa/manylinux ), [PEP 513 ](https://www.python.org/dev/peps/pep-0513/ ), [PEP 571 ](https://www.python.org/dev/peps/pep-0571/ ) and [PEP 599 ](https://www.python.org/dev/peps/pep-0599/ ) for more details).
2019-11-03 19:38:18 +00:00
2019-12-26 13:51:57 +01:00
Note that `auditwheel` detects the version of the `manylinux` standard in the Docker image through the `AUDITWHEEL_PLAT` environment variable, as `cibuildwheel` has no way of detecting the correct `--plat` command line argument to pass to `auditwheel` for a custom image. If a Docker image does not correctly set this `AUDITWHEEL_PLAT` environment variable, the `CIBW_ENVIRONMENT` option can be used to do so (e.g., `CIBW_ENVIRONMENT='AUDITWHEEL_PLAT="manylinux2010_$(uname -m)"'` ).
2019-11-03 19:38:18 +00:00
2019-12-02 11:07:56 +01:00
Note that `manylinux2014` doesn't support builds with Python 2.7 - when building with `manylinux2014` , skip Python 2.7 using `CIBW_SKIP` (see example below).
2019-11-10 14:54:56 +00:00
#### Examples
```yaml
# build using the manylinux1 image to ensure manylinux1 wheels are produced
2019-12-26 13:51:57 +01:00
# skip PyPy, since there is no PyPy manylinux1 image
2019-11-10 14:54:56 +00:00
CIBW_MANYLINUX_X86_64_IMAGE : manylinux1
CIBW_MANYLINUX_I686_IMAGE : manylinux1
2020-02-13 10:52:46 +01:00
CIBW_SKIP : pp*
2019-11-10 14:54:56 +00:00
2019-12-02 11:07:56 +01:00
# build using the manylinux2014 image
CIBW_MANYLINUX_X86_64_IMAGE : manylinux2014
CIBW_MANYLINUX_I686_IMAGE : manylinux2014
CIBW_SKIP : cp27-manylinux*
2020-02-18 09:32:02 +00:00
# build using the latest manylinux2010 release, instead of the cibuildwheel
# pinned version
CIBW_MANYLINUX_X86_64_IMAGE : quay.io/pypa/manylinux2010_x86_64:latest
CIBW_MANYLINUX_I686_IMAGE : quay.io/pypa/manylinux2010_i686:latest
2019-11-10 14:54:56 +00:00
# build using a different image from the docker registry
CIBW_MANYLINUX_X86_64_IMAGE : dockcross/manylinux-x64
CIBW_MANYLINUX_I686_IMAGE : dockcross/manylinux-x86
```
2019-09-29 21:53:18 +01:00
2020-05-17 22:26:12 +02:00
2020-01-28 22:18:37 +00:00
### `CIBW_DEPENDENCY_VERSIONS` {: #dependency-versions}
> Specify how cibuildwheel controls the versions of the tools it uses
Options: `pinned` `latest` `<your constraints file>`
Default: `pinned`
If `CIBW_DEPENDENCY_VERSIONS` is `pinned` , cibuildwheel uses versions of tools
2020-03-23 22:14:53 +00:00
like `pip` , `setuptools` , `virtualenv` that were pinned with that release of
cibuildwheel. This represents a known-good set of dependencies, and is
recommended for build repeatability.
2020-01-28 22:18:37 +00:00
If set to `latest` , cibuildwheel will use the latest of these packages that
are available on PyPI. This might be preferable if these packages have bug
fixes that can't wait for a new cibuildwheel release.
To control the versions of dependencies yourself, you can supply a [pip
constraints ](https://pip.pypa.io/en/stable/user_guide/#constraints-files ) file
here and it will be used instead.
2020-02-02 17:30:27 +00:00
!!! note
If you need different dependencies for each python version, provide them
in the same folder with a `-pythonXY` suffix. e.g. if your
`CIBW_DEPENDENCY_VERSIONS=./constraints.txt` , cibuildwheel will use
`./constraints-python27.txt` on Python 2.7, or fallback to
`./constraints.txt` if that's not found.
2020-01-28 22:18:37 +00:00
Platform-specific variants also available:<br/>
2020-02-18 09:32:02 +00:00
`CIBW_DEPENDENCY_VERSIONS_MACOS` | `CIBW_DEPENDENCY_VERSIONS_WINDOWS`
!!! note
This option does not affect the tools used on the Linux build - those versions
are bundled with the manylinux image that cibuildwheel uses. To change
dependency versions on Linux, use the [CIBW_MANYLINUX_* ](#manylinux-image )
options.
2020-01-28 22:18:37 +00:00
#### Examples
```yaml
# use tools versions that are bundled with cibuildwheel (this is the default)
CIBW_DEPENDENCY_VERSIONS : pinned
# use the latest versions available on PyPI
CIBW_DEPENDENCY_VERSIONS : latest
# use your own pip constraints file
CIBW_DEPENDENCY_VERSIONS : ./constraints.txt
```
2019-10-20 20:39:50 +01:00
## Testing
2019-09-29 21:53:18 +01:00
2020-05-31 21:42:21 +02:00
### `CIBW_TEST_COMMAND` {: #test-command}
> Execute a shell command to test each built wheel
Shell command to run tests after the build. The wheel will be installed automatically and available for import from the tests. To ensure the wheel is imported by your tests (instead of your source copy), tests are run from a different directory. Use the placeholders `{project}` and `{package}` when specifying paths in your project.
- `{project}` is an absolute path to the project root - the working directory where cibuildwheel was called.
- `{package}` is the path to the package being built - the `package_dir` argument supplied to cibuildwheel on the command line.
The command is run in a shell, so you can write things like `cmd1 && cmd2` .
Platform-specific variants also available:<br/>
`CIBW_TEST_COMMAND_MACOS` | `CIBW_TEST_COMMAND_WINDOWS` | `CIBW_TEST_COMMAND_LINUX`
#### Examples
```yaml
# run the project tests against the installed wheel using `nose`
CIBW_TEST_COMMAND : nosetests {project}/tests
# run the package tests using `pytest`
CIBW_TEST_COMMAND : pytest {package}/tests
```
2020-05-17 22:26:12 +02:00
### `CIBW_BEFORE_TEST` {: #before-test}
> Execute a shell command before testing each wheel
2019-09-29 21:53:18 +01:00
2020-05-17 22:26:12 +02:00
A shell command to run in **each** test virtual environment, before your wheel is installed and tested. This is useful if you need to install a non pip package, change values of environment variables
or perform multi step pip installation (e.g. installing `scikit-build` or `cython` before install test package)
2020-04-10 12:59:22 +01:00
2020-05-17 22:26:12 +02:00
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` .
2019-09-29 21:53:18 +01:00
2020-03-07 18:05:30 +00:00
The command is run in a shell, so you can write things like `cmd1 && cmd2` .
2019-09-29 21:53:18 +01:00
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
2020-05-17 22:26:12 +02:00
`CIBW_BEFORE_TEST_MACOS` | `CIBW_BEFORE_TEST_WINDOWS` | `CIBW_BEFORE_TEST_LINUX`
2019-11-17 19:08:22 +00:00
2019-11-10 14:54:56 +00:00
#### Examples
```yaml
2020-05-17 22:26:12 +02:00
# install test dependencies with overwritten environment variables.
CIBW_BEFORE_TEST : CC=gcc CXX=g++ pip install -r requirements.txt
2019-11-10 14:54:56 +00:00
2020-05-17 22:26:12 +02:00
# chain commands using &&
CIBW_BEFORE_TEST : rm -rf ./data/cache && mkdir -p ./data/cache
# install non pip python package
CIBW_BEFORE_TEST : cd some_dir; ./configure; make; make install
# install python packages that are required to install test dependencies
CIBW_BEFORE_TEST : pip install cmake scikit-build
2019-11-10 14:54:56 +00:00
```
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
2019-11-09 19:38:59 +00:00
### `CIBW_TEST_REQUIRES` {: #test-requires}
2019-10-20 20:39:50 +01:00
> Install Python dependencies before running the tests
2019-09-29 21:53:18 +01:00
Space-separated list of dependencies required for running the tests.
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
`CIBW_TEST_REQUIRES_MACOS` | `CIBW_TEST_REQUIRES_WINDOWS` | `CIBW_TEST_REQUIRES_LINUX`
2019-11-10 14:54:56 +00:00
#### Examples
```yaml
# install pytest before running CIBW_TEST_COMMAND
2019-11-12 23:34:59 +00:00
CIBW_TEST_REQUIRES : pytest
2019-11-10 14:54:56 +00:00
# install specific versions of test dependencies
CIBW_TEST_REQUIRES : nose==1.3.7 moto==0.4.31
```
2019-09-29 21:53:18 +01:00
2019-11-09 19:38:59 +00:00
### `CIBW_TEST_EXTRAS` {: #test-extras}
2019-10-20 20:39:50 +01:00
> Install your wheel for testing using `extras_require`
2019-09-29 21:53:18 +01:00
Comma-separated list of
[extras_require ](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies )
options that should be included when installing the wheel prior to running the
tests. This can be used to avoid having to redefine test dependencies in
`CIBW_TEST_REQUIRES` if they are already defined in `setup.py` or
`setup.cfg` .
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
`CIBW_TEST_EXTRAS_MACOS` | `CIBW_TEST_EXTRAS_WINDOWS` | `CIBW_TEST_EXTRAS_LINUX`
2019-11-10 14:54:56 +00:00
#### Examples
2019-09-29 21:53:18 +01:00
2019-11-10 14:54:56 +00:00
```yaml
# will cause the wheel to be installed with `pip install <wheel_file>[test,qt]`
2019-11-12 23:34:59 +00:00
CIBW_TEST_EXTRAS : test,qt
2019-11-10 14:54:56 +00:00
```
2019-09-29 21:53:18 +01:00
2020-01-07 09:03:14 +01:00
2019-10-20 20:39:50 +01:00
## Other
2019-09-29 21:53:18 +01:00
2019-11-10 12:08:14 +00:00
### `CIBW_BUILD_VERBOSITY` {: #build-verbosity}
2019-10-20 20:39:50 +01:00
> Increase/decrease the output of pip wheel
2019-09-29 21:53:18 +01:00
An number from 1 to 3 to increase the level of verbosity (corresponding to invoking pip with `-v` , `-vv` , and `-vvv` ), between -1 and -3 (`-q` , `-qq` , and `-qqq` ), or just 0 (default verbosity). These flags are useful while debugging a build when the output of the actual build invoked by `pip wheel` is required.
2019-11-17 19:08:22 +00:00
Platform-specific variants also available:<br/>
`CIBW_BUILD_VERBOSITY_MACOS` | `CIBW_BUILD_VERBOSITY_WINDOWS` | `CIBW_BUILD_VERBOSITY_LINUX`
2019-11-10 14:54:56 +00:00
#### Examples
```yaml
# increase pip debugging output
CIBW_BUILD_VERBOSITY : 1
```
2019-09-29 21:53:18 +01:00
## Command line options
2019-10-06 20:36:21 +01:00
```text
2019-09-29 21:53:18 +01:00
usage: cibuildwheel [-h] [--platform {auto,linux,macos,windows}]
[--output-dir OUTPUT_DIR] [--print-build-identifiers]
2020-04-10 12:59:22 +01:00
[package_dir]
2019-11-12 23:34:59 +00:00
2019-09-29 21:53:18 +01:00
Build wheels for all the platforms.
positional arguments:
2020-04-10 12:59:22 +01:00
package_dir Path to the package that you want wheels for. Must be
a subdirectory of the working directory. When set, the
working directory is still considered the 'project'
and is copied into the Docker container on Linux.
Default: the working directory.
2019-09-29 21:53:18 +01:00
optional arguments:
-h, --help show this help message and exit
--platform {auto,linux,macos,windows}
Platform to build for. For "linux" you need docker
running, on Mac or Linux. For "macos", you need a Mac
machine, and note that this script is going to
automatically install MacPython on your system, so
don't run on your development machine. For "windows",
you need to run in Windows, and it will build and test
2020-04-10 12:59:22 +01:00
for all versions of Python. Default: auto.
2019-09-29 21:53:18 +01:00
--output-dir OUTPUT_DIR
Destination folder for the wheels.
--print-build-identifiers
Print the build identifiers matched by the current
invocation and exit.
```
2019-10-06 20:36:21 +01:00
<style>
2019-10-20 20:39:50 +01:00
.toctree-l3 {
border-left: 10px solid transparent;
}
2019-11-03 19:11:38 +00:00
2019-10-20 20:39:50 +01:00
.options-toc {
display: grid;
grid-auto-columns: fit-content(20%) 1fr;
2019-11-03 18:35:06 +00:00
grid-gap: 16px 32px;
gap: 16px 32px;
2019-10-20 20:39:50 +01:00
font-size: 90%;
2019-11-03 19:11:38 +00:00
margin-bottom: 28px;
margin-top: 28px;
2019-10-20 20:39:50 +01:00
}
.options-toc .header {
grid-column: 1 / 3;
font-weight: bold;
}
.options-toc .header:first-child {
margin-top: 0;
}
2019-11-03 18:35:06 +00:00
.options-toc a.option {
display: block;
margin-bottom: 5px;
}
2019-11-10 14:54:56 +00:00
h3 code {
font-size: 100%;
}
2019-10-06 20:36:21 +01:00
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
2019-11-03 18:35:06 +00:00
// gather the options data
2019-10-20 20:39:50 +01:00
var options = {}
var headers = []
$('.rst-content h3')
.filter(function (i, el) {
return !!$(el).text().match(/(^([A-Z0-9, _]| and )+)¶$/);
})
.each(function (i, el) {
var optionName = $(el).text().replace('¶', '');
var description = $(el).next('blockquote').text()
var header = $(el).prevAll('h2').first().text().replace('¶', '')
var id = el.id;
if (options[header] === undefined) {
options[header] = [];
headers.push(header);
}
console.log(optionName, description, header);
options[header].push({name: optionName, description, id});
});
2019-11-12 23:34:59 +00:00
2019-11-03 18:35:06 +00:00
// write the table of contents
2019-10-20 20:39:50 +01:00
var tocTable = $('.options-toc');
for (var i = 0; i < headers.length; i += 1) {
var header = headers[i];
var headerOptions = options[header];
$('<div class="header">').text(header).appendTo(tocTable);
for (var j = 0; j < headerOptions.length; j += 1) {
var option = headerOptions[j];
2019-11-03 18:35:06 +00:00
var optionNames = option.name.split(', ')
$('<div class="name">')
.append($.map(optionNames, function (name) {
return $('<a class="option">')
.append(
$('<code>').text(name)
)
.attr('href', '#'+option.id)
}
))
.appendTo(tocTable);
$('<div class="description">')
.text(option.description)
2019-10-20 20:39:50 +01:00
.appendTo(tocTable);
}
}
2019-11-03 19:06:48 +00:00
// write the markdown table for the README
var markdown = ''
markdown += '| | Option | Description |\n'
markdown += '|---|--------|-------------|\n'
var prevHeader = null
for (var i = 0; i < headers.length; i += 1) {
var header = headers[i];
var headerOptions = options[header];
for (var j = 0; j < headerOptions.length; j += 1) {
var option = headerOptions[j];
if (j == 0) {
markdown += '| ** '+header+'** '
} else {
markdown += '| '
}
var optionNames = option.name.trim().split(', ')
var url = 'https://cibuildwheel.readthedocs.io/en/stable/options/#'+option.id;
var namesMarkdown = $.map(optionNames, function(n) {
return '[`'+n+'` ]('+url+' ) '
2020-06-23 09:59:22 +01:00
}).join(' <br> ')
2019-11-03 19:06:48 +00:00
markdown += '| '+namesMarkdown+' '
markdown += '| '+option.description.trim()+' '
markdown += '|\n'
}
}
console.log('readme options markdown\n', markdown)
2019-10-20 20:39:50 +01:00
});
2019-10-06 20:36:21 +01:00
</script>