Files
cibuildwheel/README.md
T

397 lines
17 KiB
Markdown
Raw Normal View History

2017-03-19 20:57:51 +00:00
cibuildwheel
============
2018-09-05 04:15:32 -04:00
[![PyPI](https://img.shields.io/pypi/v/cibuildwheel.svg)](https://pypi.python.org/pypi/cibuildwheel) [![Build Status](https://travis-ci.org/joerick/cibuildwheel.svg?branch=master)](https://travis-ci.org/joerick/cibuildwheel) [![Build status](https://ci.appveyor.com/api/projects/status/wbsgxshp05tt1tif/branch/master?svg=true)](https://ci.appveyor.com/project/joerick/cibuildwheel/branch/master) [![CircleCI](https://circleci.com/gh/joerick/cibuildwheel.svg?style=svg)](https://circleci.com/gh/joerick/cibuildwheel)
2017-03-21 09:50:25 +00:00
2017-03-19 20:57:51 +00:00
Python wheels are great. Building them across **Mac, Linux, Windows**, on **multiple versions of Python**, is not.
`cibuildwheel` is here to help. `cibuildwheel` runs on your CI server - currently it supports Azure Pipelines, Travis CI, AppVeyor, and CircleCI - and it builds and tests your wheels across all of your platforms.
2017-03-19 20:57:51 +00:00
**`cibuildwheel` is in beta**. It's brand new - I'd love for you to try it and help make it better!
What does it do?
----------------
| | macOS 10.6+ | manylinux i686 | manylinux x86_64 | Windows 32bit | Windows 64bit |
|---|---|---|---|---|---|
2019-04-06 16:18:17 +01:00
| Python 2.7 | ✅ | ✅ | ✅ | ✅ | ✅ |
| Python 3.4 | ✅ | ✅ | ✅ | ✅* | ✅* |
| Python 3.5 | ✅ | ✅ | ✅ | ✅ | ✅ |
| Python 3.6 | ✅ | ✅ | ✅ | ✅ | ✅ |
| Python 3.7 | ✅ | ✅ | ✅ | ✅ | ✅ |
2018-07-10 19:03:38 +01:00
2019-04-22 19:05:34 +01:00
> \* Not supported on Azure Pipelines
2019-04-06 16:18:17 +01:00
- Builds manylinux, macOS and Windows (32 and 64bit) wheels using Azure Pipelines, Travis CI, AppVeyor, and CircleCI
2017-03-19 20:57:51 +00:00
- Bundles shared library dependencies on Linux and macOS through [auditwheel](https://github.com/pypa/auditwheel) and [delocate](https://github.com/matthew-brett/delocate)
- Runs the library test suite against the wheel-installed version of your library
Usage
-----
`cibuildwheel` currently works **Travis CI** and **CircleCI** to build Linux and Mac wheels, and **AppVeyor** to build Windows wheels. **Azure Pipelines** supports all three.
2019-04-06 16:18:17 +01:00
| | Linux | macOS | Windows |
|-----------------|-------|-------|---------|
| Azure Pipelines | ✅ | ✅ | ✅ |
| Travis CI | ✅ | ✅ | |
| AppVeyor | | | ✅ |
2019-04-06 16:18:17 +01:00
| CircleCI | ✅ | ✅ | |
2017-03-19 20:57:51 +00:00
`cibuildwheel` is not intended to run on your development machine. It will try to install packages globally; this is no good. Travis CI, CircleCI, and AppVeyor run their builds in isolated environments, so are ideal for this kind of script.
2017-03-19 20:57:51 +00:00
2017-09-16 23:03:14 +02:00
### Linux builds on Docker
2017-09-19 20:09:59 +01:00
Linux wheels are built in the [`manylinux1` docker images](https://github.com/pypa/manylinux) to provide binary compatible wheels on Linux, according to [PEP 513](https://www.python.org/dev/peps/pep-0513/). Because of this, when building with `cibuildwheel` on Linux, a few things should be taken into account:
- Programs and libraries cannot be installed on the Travis CI Ubuntu host with `apt-get`, but can be installed inside of the Docker image using `yum` or manually. The same goes for environment variables that are potentially needed to customize the wheel building. `cibuildwheel` supports this by providing the `CIBW_ENVIRONMENT` and `CIBW_BEFORE_BUILD` options to setup the build environment inside the running Docker image. See [below](#options) for details on these options.
2018-09-05 04:15:32 -04:00
- The project directory is mounted in the running Docker instance as `/project`, the output directory for the wheels as `/output`. In general, this is handled transparently by `cibuildwheel`. For a more finegrained level of control however, the root of the host file system is mounted as `/host`, allowing for example to access shared files, caches, etc. on the host file system. Note that this is not available on CircleCI due to their Docker policies.
- Alternative dockers images can be specified with the `CIBW_MANYLINUX1_X86_64_IMAGE` and `CIBW_MANYLINUX1_I686_IMAGE` options to allow for a custom, preconfigured build environment for the Linux builds. See [below](#options) for more details.
2017-09-16 23:03:14 +02:00
2017-03-19 20:57:51 +00:00
Options
-------
```
usage: cibuildwheel [-h] [--platform {auto,linux,macos,windows}]
[--output-dir OUTPUT_DIR] [--print-build-identifiers]
2017-03-19 20:57:51 +00:00
[project_dir]
Build wheels for all the platforms.
positional arguments:
project_dir Path to the project that you want wheels for.
Default: the current directory.
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
for all versions of Python at C:\PythonXX[-x64].
--output-dir OUTPUT_DIR
Destination folder for the wheels.
--print-build-identifiers
Print the build identifiers matched by the current
invocation and exit.
2017-03-19 20:57:51 +00:00
```
2018-08-19 21:06:43 -07:00
### Example YML syntax
2017-03-19 20:57:51 +00:00
<table>
<tr><td><i>example .travis.yml environment variables</i><pre><code>env:
global:
- CIBW_TEST_REQUIRES=nose
- CIBW_TEST_COMMAND="nosetests {project}/tests"
</code></pre></td>
<td><i>example appveyor.yml environment variables</i><pre><code>environment:
global:
CIBW_TEST_REQUIRES: nose
CIBW_TEST_COMMAND: "nosetests {project}\\tests"
</code></pre></td>
</tr></table>
2017-03-20 23:04:35 +00:00
Delivering to PyPI
------------------
After you've built your wheels, you'll probably want to deliver them to PyPI.
### Manual method
On your development machine, do the following...
```bash
# Clear out your 'dist' folder.
rm -rf dist
# Make a source distribution
python setup.py sdist
# 🏃🏻
# Go and download your wheel files from wherever you put them. Put
# them all into the 'dist' folder.
# Upload using 'twine' (you may need to 'pip install twine')
twine upload dist/*
```
### Semi-automatic method using wheelhouse-uploader
Obviously, manual steps are for chumps, so we can automate this a little by using [wheelhouse-uploader](https://github.com/ogrisel/wheelhouse-uploader).
> Quick note from me - using S3 as a storage didn't work due to a [bug](https://issues.apache.org/jira/browse/LIBCLOUD-792) in libcloud. Feel free to use my fork of that package that fixes the bug `pip install https://github.com/joerick/libcloud/archive/v1.5.0-s3fix.zip`
2017-04-23 13:25:40 +01:00
### Automatic method
If you don't need much control over the release of a package, you can set up cibuildwheel to deliver the wheels straight to PyPI. This doesn't require any cloud storage to work - you just need to bump the version and tag it.
Check out [this example repo](https://github.com/joerick/cibuildwheel-autopypi-example) for instructions on how to set this up.
2017-03-19 20:57:51 +00:00
It didn't work!
---------------
If your wheel didn't compile, check the list below for some debugging tips.
2017-03-20 23:04:35 +00:00
- A mistake in your config. To quickly test your config without doing a git push and waiting for your code to build on CI, you can run the Linux build in a Docker container. On Mac or Linux, with Docker running, try `cibuildwheel --platform linux`. You'll have to bring your config into the current environment first.
2018-09-05 04:15:32 -04:00
- Missing dependency. You might need to install something on the build machine. You can do this in `.travis.yml`, `appveyor.yml`, or `.circleci/config.yml`, with apt-get, brew or whatever Windows uses :P . Given how the Linux build works, we'll probably have to build something into `cibuildwheel`. Let's chat about that over in the issues!
2017-03-19 20:57:51 +00:00
- Windows: missing C feature. The Windows C compiler doesn't support C language features invented after 1990, so you'll have to backport your C code to C90. For me, this mostly involved putting my variable declarations at the top of the function like an animal.
2019-04-05 21:31:50 +01:00
- MacOS: calling cibuildwheel from a python3 script and getting a `ModuleNotFoundError`? Due to a [bug](https://bugs.python.org/issue22490) in CPython, you'll need to [unset the `__PYVENV_LAUNCHER__` variable](https://github.com/joerick/cibuildwheel/issues/133#issuecomment-478288597) before activating a venv.
2017-03-19 20:57:51 +00:00
2017-03-20 23:04:35 +00:00
Working examples
----------------
Here are some repos that use cibuildwheel.
- [pyinstrument_cext](https://github.com/joerick/pyinstrument_cext)
2017-08-20 14:16:07 +02:00
- [websockets](https://github.com/aaugustin/websockets)
- [Parselmouth](https://github.com/YannickJadoul/Parselmouth)
- [python-admesh](https://github.com/admesh/python-admesh)
- [pybase64](https://github.com/mayeut/pybase64)
- [KDEpy](https://github.com/tommyod/KDEpy)
2018-09-14 12:36:46 -07:00
- [AutoPy](https://github.com/autopilot-rs/autopy)
2018-10-18 00:04:25 -07:00
- [apriltags2-ethz](https://github.com/safijari/apriltags2_ethz)
2019-06-14 21:38:38 +02:00
- [TgCrypto](https://github.com/pyrogram/tgcrypto)
2019-08-28 23:06:38 -04:00
- [Twisted](https://github.com/twisted/twisted)
2017-03-20 23:04:35 +00:00
> Add repo here! Send a PR.
2017-03-19 20:57:51 +00:00
Legal note
----------
2018-09-23 22:07:36 +01:00
Since `cibuildwheel` runs the wheel through delocate or auditwheel, it might automatically bundle dynamically linked libraries from the build machine.
It helps ensure that the library can run without any dependencies outside of the pip toolchain.
This is similar to static linking, so it might have some licence implications. Check the license for any code you're pulling in to make sure that's allowed.
2017-03-19 20:57:51 +00:00
2017-06-11 16:32:13 +01:00
Changelog
=========
2019-09-29 20:46:23 +01:00
### 0.12.0
_29 September 2019_
- ✨ Add CIBW_TEST_EXTRAS option, to allow testing using extra_require
options. For example, set `CIBW_TEST_EXTRAS=test,qt` to make the wheel
installed with `pip install <wheel_file>[test,qt]`
- 🛠 Update Python from 3.7.2 to 3.7.4 on macOS
- 🛠 Update OpenSSL patch to 1.0.2t on macOS
2019-05-28 19:22:25 +01:00
### 0.11.1
_28 May 2019_
- 🐛 Fix missing file in the release tarball, that was causing problems with
Windows builds (#141)
2019-05-26 12:53:51 +01:00
### 0.11.0
_26 May 2019_
- ✨ Add support for building on Azure pipelines! This lets you build all
Linux, Mac and Windows wheels on one service, so it promises to be the
easiest to set up! Check out the quickstart in the docs, or
[cibuildwheel-azure-example](https://github.com/joerick/cibuildwheel-azure-example)
for an example project. (#126, #132)
- 🛠 Internal change - the end-to-end test projects format was updated, so we
can more precisely assert what should be produced for each one. (#136, #137).
2019-03-10 23:37:36 +00:00
### 0.10.2
_10 March 2019_
- 🛠 Revert temporary fix in macOS, that was working around a bug in pip 19 (#129)
- 🛠 Update Python to 2.7.16 on macOS
- 🛠 Update OpenSSL patch to 1.0.2r on macOS
2019-02-03 21:58:53 +00:00
### 0.10.1
2019-02-14 11:58:56 +08:00
_3 February 2019_
2019-02-03 21:58:53 +00:00
- 🐛 Fix build stalling on macOS (that was introduced in pip 19) (#122)
- 🐛 Fix "AttributeError: 'Popen' object has no attribute 'args'" on Python 2.7 for Linux builds (#108)
- 🛠 Update Python from 3.6.7, 3.7.1 to 3.6.8, 3.7.2 on macOS
- 🛠 Update openssl patch from 1.0.2p to 1.0.2q on macOS
- 🛠 Sorting build options dict items when printing preamble (#114)
2018-09-23 22:07:47 +01:00
### 0.10.0
2018-09-08 18:14:35 +01:00
2018-09-23 22:07:47 +01:00
_23 September 2018_
- ✨ Add `CIBW_BUILD` option, for specifying which specific builds to perform (#101)
- ✨ Add support for building Mac and Linux on CircleCI (#91, #97)
- 🛠 Improved support for building universal wheels (#95)
2018-09-08 18:14:35 +01:00
- 🛠 Ensure log output is unbuffered and therefore in the correct order (#92)
- 🛠 Improved error reporting for errors that occur inside a package's setup.py (#88)
- ⚠️ Removed support for Python 3.3 on Windows.
2018-07-29 18:21:19 +01:00
### 0.9.4
2018-09-23 22:07:47 +01:00
_29 July 2018_
2018-07-29 18:21:19 +01:00
- 🛠 CIBW_TEST_COMMAND now runs in a shell on Mac (as well as Linux) (#81)
2018-07-10 19:03:38 +01:00
### 0.9.3
2018-09-23 22:07:47 +01:00
_10 July 2018_
2018-07-10 19:03:38 +01:00
- 🛠 Update to Python 3.6.6 on macOS (#82)
- ✨ Add support for building Python 3.7 wheels on Windows (#76)
- ⚠️ Deprecated support for Python 3.3 on Windows.
2018-07-01 21:30:53 +01:00
### 0.9.2
2018-09-23 22:07:47 +01:00
_1 July 2018_
2018-07-01 21:30:53 +01:00
- 🛠 Update Python 3.7.0rc1 to 3.7.0 on macOS (#79)
2018-06-18 23:17:42 +01:00
### 0.9.1
2018-09-23 22:07:47 +01:00
_18 June 2018_
2018-06-18 23:17:42 +01:00
- 🛠 Removed the need to use `{python}` and `{pip}` in `CIBW_BEFORE_BUILD` statements, by ensuring the correct version is always on the path at `python` and `pip` instead. (#60)
- 🛠 We now patch the _ssl module on Python 3.4 and 3.5 so these versions can still make SSL web requests using TLS 1.2 while building. (#71)
2018-06-18 22:57:22 +01:00
### 0.9.0
2018-09-23 22:07:47 +01:00
_18 June 2018_
2018-06-18 23:17:42 +01:00
- ✨ Add support for Python 3.7 (#73)
2018-06-18 22:57:22 +01:00
2018-05-04 10:21:34 -07:00
### 0.8.0
2018-09-23 22:07:47 +01:00
_4 May 2018_
2018-06-18 23:17:42 +01:00
- ⚠️ Drop support for Python 3.3 on Linux (#67)
- 🐛 Fix TLS by updating setuptools (#69)
2018-05-04 10:21:34 -07:00
2018-04-02 15:50:59 +01:00
### 0.7.1
2018-09-23 22:07:47 +01:00
_2 April 2017_
2018-06-18 23:17:42 +01:00
- 🐛 macOS: Fix Pip bugs resulting from PyPI TLS 1.2 enforcement
- 🐛 macOS: Fix brew Python3 version problems in the CI
2018-04-02 15:50:59 +01:00
2018-01-07 18:10:27 +00:00
### 0.7.0
2018-09-23 22:07:47 +01:00
_7 January 2018_
2018-06-18 23:17:42 +01:00
- ✨ You can now specify a custom docker image using the `CIBW_MANYLINUX1_X86_64_IMAGE` and `CIBW_MANYLINUX1_I686_IMAGE` options. (#46)
- 🐛 Fixed a bug where cibuildwheel would download and build a package from PyPI(!) instead of building the package on the local machine. (#51)
2018-01-07 18:10:27 +00:00
2017-10-09 19:26:45 +01:00
### 0.6.0
2018-09-23 22:07:47 +01:00
_9 October 2017_
2018-06-18 23:17:42 +01:00
- ✨ On the Linux build, the host filesystem is now accessible via `/host` (#36)
- 🐛 Fixed a bug where setup.py scripts would run the wrong version of Python when running subprocesses on Linux (#35)
2017-10-09 19:26:45 +01:00
2017-09-10 22:52:15 +01:00
### 0.5.1
2018-09-23 22:07:47 +01:00
_10 September 2017_
2018-06-18 23:17:42 +01:00
- 🐛 Fixed a couple of bugs on Python 3.
- ✨ Added experimental support for Mac builds on [Bitrise.io](https://www.bitrise.io)
2017-09-10 22:52:15 +01:00
2017-09-07 23:06:08 +01:00
### 0.5.0
2018-09-23 22:07:47 +01:00
_7 September 2017_
2018-06-18 23:17:42 +01:00
-`CIBW_ENVIRONMENT` added. You can now set environment variables for each build, even within the Docker container on Linux. This is a big one! (#21)
-`CIBW_BEFORE_BUILD` now runs in a system shell on all platforms. You can now do things like `CIBW_BEFORE_BUILD="cmd1 && cmd2"`. (#32)
2017-09-07 23:06:08 +01:00
2017-08-14 21:39:42 +01:00
### 0.4.1
2018-09-23 22:07:47 +01:00
_14 August 2017_
2018-06-18 23:17:42 +01:00
- 🐛 Fixed a bug on Windows where subprocess' output was hidden (#23)
- 🐛 Fixed a bug on AppVeyor where logs would appear in the wrong order due to output buffering (#24, thanks @YannickJadoul!)
2017-08-14 21:39:42 +01:00
2017-07-23 22:39:15 +01:00
### 0.4.0
2018-09-23 22:07:47 +01:00
_23 July 2017_
2018-06-18 23:17:42 +01:00
- 🐛 Fixed a bug that was increasing the build time by building the wheel twice. This was a problem for large projects that have a long build time. If you're upgrading and you need the old behaviour, use `CIBW_BEFORE_BUILD={pip} install .`, or install exactly the dependencies you need in `CIBW_BEFORE_BUILD`. See #18.
2017-07-23 22:39:15 +01:00
2017-06-27 18:18:07 +01:00
### 0.3.0
2018-09-23 22:07:47 +01:00
_27 June 2017_
2018-06-18 23:17:42 +01:00
- ⚠️ Removed Python 2.6 support on Linux (#12)
2017-06-27 18:18:07 +01:00
2017-06-11 16:32:13 +01:00
### 0.2.1
2018-09-23 22:07:47 +01:00
_11 June 2017_
2017-06-11 16:32:13 +01:00
2018-06-18 23:17:42 +01:00
- 🛠 Changed the build process to install the package before building the wheel - this allows direct dependencies to be installed first (#9, thanks @tgarc!)
- ✨ Added Python 3 support for the main process, for systems where Python 3 is the default (#8, thanks @tgarc).
2017-06-11 16:32:13 +01:00
### 0.2.0
2018-09-23 22:07:47 +01:00
_13 April 2017_
2017-06-11 16:32:13 +01:00
2018-06-18 23:17:42 +01:00
- ✨ Added `CIBW_SKIP` option, letting users explicitly skip a build
- ✨ Added `CIBW_BEFORE_BUILD` option, letting users run a shell command before the build starts
2017-06-11 16:32:13 +01:00
### 0.1.3
2018-09-23 22:07:47 +01:00
_31 March 2017_
2017-06-11 16:32:13 +01:00
2018-06-18 23:17:42 +01:00
- 🌟 First public release!
2017-03-19 20:57:51 +00:00
Contributing
============
Wheel-building is pretty complex. I expect users to find many edge-cases - please help the rest of the community out by documenting these, adding features to support them, and reporting bugs.
I plan to be pretty liberal in accepting pull requests, as long as they align with the design goals below.
`cibuildwheel` is indie open source. I'm not paid to work on this.
Design Goals
------------
- `cibuildwheel` should wrap the complexity of wheel building.
- The user interface to `cibuildwheel` is the build script (e.g. `.travis.yml`). Feature additions should not increase the complexity of this script.
- Options should be environment variables (these lend themselves better to YML config files). They should be prefixed with `CIBW_`.
- Options should be generalise to all platforms. If platform-specific options are required, they should be namespaced e.g. `CIBW_TEST_COMMAND_MACOS`
Other notes:
- The platforms are very similar, until they're not. I'd rather have straight-forward code than totally DRY code, so let's keep airy platfrom abstractions to a minimum.
- I might want to break the options into a shared config file one day, so that config is more easily shared. That has motivated some of the design decisions.
2017-07-13 22:20:33 +01:00
Maintainers
-----------
2017-07-13 22:21:44 +01:00
- Joe Rickerby [@joerick](https://github.com/joerick)
- Tomas Garcia [@tgarc](https://github.com/tgarc)
2017-09-06 14:22:44 +01:00
- Yannick Jadoul [@YannickJadoul](https://github.com/YannickJadoul)
- Matthieu Darbois [@mayeut](https://github.com/mayeut)
2017-07-13 22:20:33 +01:00
2017-03-19 20:57:51 +00:00
Credits
-------
2018-06-18 22:57:22 +01:00
`cibuildwheel` stands on the shoulders of giants.
2017-03-19 20:57:51 +00:00
2017-03-19 21:49:26 +00:00
- ⭐️ @matthew-brett for [matthew-brett/multibuild](http://github.com/matthew-brett/multibuild) and [matthew-brett/delocate](http://github.com/matthew-brett/delocate)
- @PyPA for the manylinux Docker images [pypa/manylinux](https://github.com/pypa/manylinux)
- @ogrisel for [wheelhouse-uploader](https://github.com/ogrisel/wheelhouse-uploader) and `run_with_env.cmd`
2018-06-18 22:57:22 +01:00
2018-06-18 23:17:42 +01:00
Massive props also to-
2018-06-18 22:57:22 +01:00
2017-04-12 09:59:58 +01:00
- @zfrenchee for [help debugging many issues](https://github.com/joerick/cibuildwheel/issues/2)
2018-06-18 22:57:22 +01:00
- @lelit for some great bug reports and [contributions](https://github.com/joerick/cibuildwheel/pull/73)
2018-06-18 23:17:42 +01:00
- @mayeut for a [phenomenal PR](https://github.com/joerick/cibuildwheel/pull/71) patching Python itself for better compatibility!
2017-03-19 20:57:51 +00:00
See also
--------
2019-01-07 22:17:19 +00:00
If you'd like to keep wheel building separate from the package itself, check out [astrofrog/autowheel](https://github.com/astrofrog/autowheel). It builds packages using cibuildwheel from source distributions on PyPI.
2017-03-19 21:49:26 +00:00
If `cibuildwheel` is too limited for your needs, consider [matthew-brett/multibuild](http://github.com/matthew-brett/multibuild). `multibuild` is a toolbox for building a wheel on various platforms. It can do a lot more than this project - it's used to build SciPy!