Compare commits

...
75 Commits
Author SHA1 Message Date
Joe Rickerby 96e3964972 Bump version: v1.8.0 2021-01-22 19:18:49 +00:00
Joe Rickerby 07f972f6d3 A few docs fixes 2021-01-22 19:16:32 +00:00
Joe Rickerby d87b589791 Merge pull request #545 from henryiii/fix/err-if-empty
feat: error if empty build selection, Travis 2.7 Win w/ workaround
2021-01-22 18:37:52 +00:00
Henry Schreiner ff8f881098 refactor: pull arch out into separate file 2021-01-22 13:02:51 -05:00
Henry Schreiner f5b84797e5 fix: move and simplify arch check 2021-01-22 13:01:00 -05:00
Henry Schreiner cc0e7ec0a1 fix: review from @joerick 2021-01-22 13:01:00 -05:00
Henry Fredrick Schreiner 5762aa5e3b feat: allow-empty and simpler testing 2021-01-22 13:01:00 -05:00
Henry Fredrick Schreiner eb9850dbde feat: support Windows workaround on Travis CI 2021-01-22 13:01:00 -05:00
Henry Fredrick Schreiner c90c7666b9 tests: fix arch for platform tests 2021-01-22 13:01:00 -05:00
Henry Fredrick Schreiner 61b94434b2 fix: error if build selectors are empty 2021-01-22 13:01:00 -05:00
Henry Fredrick Schreiner 27a0053386 fix: error if selector is empty 2021-01-22 13:01:00 -05:00
Joe Rickerby e75a3d480a Merge pull request #552 from henryiii/docs/sync
docs: update for some new packages
2021-01-22 10:02:18 +00:00
Henry Schreiner da19ac30e6 docs: fix build info 2021-01-21 12:29:02 -05:00
Henry Schreiner 98b5ff447d docs: update for some new packages 2021-01-21 12:02:58 -05:00
Henry SchreinerandJoe Rickerby fba65a6008 feat: CIBW_TEST_SKIP (#537)
* feat: CIBW_TEST_SKIP

* refactor: adjust a bit and add docs

* fix: typo in name

* docs: Update docs/options.md

Co-authored-by: Joe Rickerby <joerick@mac.com>

* docs: add README line from markdown

Co-authored-by: Joe Rickerby <joerick@mac.com>
2021-01-20 21:22:48 -05:00
Joe Rickerby 6d92dbc555 docs: massive props! (#549)
Adding some long overdue 'props' to the README to thank @Czaki and @mattip for their contributions to the project!

(thanks @henryiii for the reminder!)
2021-01-20 19:30:47 -05:00
Henry Schreiner 4a02410632 fix: action still runs if setup-python is not called (#542)
* fix: action works if setup-python is missed

* fix: two steps

* fix: combine again

* fix: use pipx for action
2021-01-20 18:16:15 -05:00
github-actions[bot] 03f83455d8 Update dependencies (#546) 2021-01-18 08:29:10 -05:00
Henry Schreiner 1441972046 fix: improve correctness of exits (#539)
* fix: improve correctness of exits

* refactor: use sys.exit
2021-01-17 14:13:26 -05:00
Henry Schreiner 45c3c2ea8e fix: empty image check (#543) 2021-01-17 13:08:55 -05:00
Joe Rickerby fbd5bc707f Update pinned version 2021-01-16 11:49:04 +00:00
Henry SchreinerandJoe Rickerby e91d8d82a2 feat: support brace expansion in BUILD/SKIP (#527)
* wip: try wcmatch

* feat: expand braces

* docs: mention brace expansion

* docs: more reasonable examples of brackets

* Update docs/options.md

Co-authored-by: Joe Rickerby <joerick@mac.com>

Co-authored-by: Joe Rickerby <joerick@mac.com>
2021-01-15 15:25:22 -05:00
d394386318 feat: update python versions as part of update_dependencies (#496)
* Update python versions as part of update_dependencies

* refactor: pulling out to update_pythons

* refactor: rewrite and expect install

* feat: support macos too, logging output

* WIP: update

* refactor: drive from original file

* Remove unused variable

* Output a diff instead of the result file, to review changes more easily

* fix: minor cleanup

Co-authored-by: Henry Fredrick Schreiner <henry.fredrick.schreiner@cern.ch>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Joe Rickerby <joerick@mac.com>
2021-01-15 14:40:03 +00:00
Henry Schreiner ca7871ce0c feat: native / all archs (#535)
* feat: native / all archs

* docs: mention new options
2021-01-15 14:38:47 +00:00
Henry SchreinerandJoe Rickerby b627134e16 docs: normalize CI list (#532)
* docs: normalize CI list

Closes #531

* Apply suggestions from code review

Co-authored-by: Joe Rickerby <joerick@mac.com>

Co-authored-by: Joe Rickerby <joerick@mac.com>
2021-01-12 23:34:47 +00:00
github-actions[bot]andmayeut f6eea06dd2 chore: update dependencies (#530)
Co-authored-by: mayeut <mayeut@users.noreply.github.com>
2021-01-11 09:37:11 -05:00
Henry SchreinerandJoe Rickerby 8b22048dea docs: drop double install and add a few projects (#520)
* docs: project update

* docs: pyproject.toml mention

* Apply suggestions from code review

Co-authored-by: Joe Rickerby <joerick@mac.com>

* docs: one more change from @joerick, dropped double install example

Co-authored-by: Joe Rickerby <joerick@mac.com>
2021-01-09 15:41:41 -05:00
Henry Schreiner 5eb5ea10f5 refactor: identifiers in a file (#511)
* refactor: identifiers in a file

* chore: more typing

* refactor: PlatStr -> PlatformName

* refactor: load in file, use importlib.resources

* refactor: change toml structure

* refactor: use common Traversable

* fix: ensure reasonable version of importlib_resources

* style: fix extra line
2021-01-09 15:40:40 -05:00
Henry Fredrick Schreiner 635b226a6c style: pre-commit run -a 2021-01-06 18:10:32 -05:00
Henry Fredrick Schreiner b1e5b8b647 style: isort 2021-01-06 18:10:32 -05:00
probot-auto-merge[bot] 9f610d0f5f Merge pull request #507 from henryiii/feat/windowsfilter
feat: Windows filtering and sets
2021-01-05 23:19:39 +00:00
Henry Schreiner fce7c70a63 refactor: standard arch checking in one place 2021-01-05 13:23:54 -05:00
probot-auto-merge[bot] 6f28d7851f Merge pull request #512 from joerick/update-dependencies-pr
[Bot] Update dependencies
2021-01-04 07:27:07 +00:00
mayeut 42616735cf Update dependencies 2021-01-04 06:14:55 +00:00
Henry Fredrick SchreinerandMatthieu Darbois a99e0ded76 feat: Windows filtering and sets
Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>
2021-01-02 22:51:16 -05:00
probot-auto-merge[bot] 1cfd5ed265 Merge pull request #510 from henryiii/style/pyupgrade
style: pyupgrade
2021-01-03 01:32:54 +00:00
Henry Fredrick Schreiner e9423a0d7f style: reorder checks 2021-01-02 19:13:31 -05:00
Henry Fredrick Schreiner 7e80e4b0b6 style: pyupgrade 2021-01-02 19:11:40 -05:00
Henry Schreiner 2a73fee411 fix: enable and fix full type checking (#509)
* fix: enable and fix fully type checking

* chore: pre-commit autoupdate

* refactor: pull types out to file
2021-01-02 14:32:55 -05:00
Henry Schreiner bc8716c188 refactor: setup.cfg and dev requirements (#504)
* refactor: use setup.cfg instead

* refactor: use dev extra

* fix: restore dev requiremetns
2021-01-02 11:33:38 -05:00
Joe Rickerby 10c052b5ef Merge branch '1.7.x' 2021-01-02 11:48:52 +00:00
Joe Rickerby 4be9285fc7 Bump version: v1.7.4 2021-01-02 11:47:05 +00:00
Joe Rickerby d3bcfe431f Merge pull request #506 from Czaki/macos_patch_fix
Macos patch fix
2021-01-02 11:43:30 +00:00
Joe Rickerby 0b5ac86ae1 Merge pull request #506 from Czaki/macos_patch_fix
Macos patch fix
2021-01-02 11:41:05 +00:00
Grzegorz Bokota 122a0e62c2 use -p1 2021-01-01 19:37:06 +01:00
Grzegorz Bokota 9888a6d88f use -i syntax for patch 2021-01-01 18:31:04 +01:00
Joe Rickerby 5c695593f3 Merge pull request #482 from asfaltboy/support-quemu-on-github
Support qemu in GitHub Actions
2021-01-01 17:21:24 +00:00
Joe Rickerby aa871284fc Make the StrEnums proper Enums 2020-12-31 16:35:26 +00:00
Joe Rickerby 5b5078e5e9 Copy edit of --archs help text to make 'auto' clearer 2020-12-31 15:45:02 +00:00
Joe Rickerby d65da2ee46 docs edits from review 2020-12-31 15:44:27 +00:00
Joe Rickerby f43407210a option ordering 2020-12-31 15:22:19 +00:00
Joe Rickerby 5ee663fe12 Add test for failure when setting CIBW_ARCHS on macos/windows 2020-12-31 15:17:24 +00:00
Joe Rickerby b5f5437114 Suggestion from review 2020-12-31 14:59:45 +00:00
Joe Rickerby 0893731090 Simplify arch matching code 2020-12-28 00:43:24 +00:00
Joe Rickerby 6b00931dca Allow the testing of any of the example configs in /examples 2020-12-23 21:11:08 +00:00
Joe Rickerby f6ce1c931d Update example config 2020-12-23 19:29:52 +00:00
Joe Rickerby 460eaa7330 Add mini-guide to the FAQ section 2020-12-23 19:23:58 +00:00
Joe Rickerby 3983fb2049 Fix broken link in docs 2020-12-23 19:18:53 +00:00
Joe Rickerby 68dc286714 Add docs for ARCHS option 2020-12-23 19:08:23 +00:00
Joe Rickerby 3696f15109 Add example github config 2020-12-23 18:42:22 +00:00
Joe Rickerby eb03a118e2 Rename Architecture to match value amd64 -> AMD64 2020-12-23 18:34:16 +00:00
Joe Rickerby b34bdeec40 Fix native archs expansion for windows 2020-12-21 16:34:36 +00:00
Joe Rickerby 8a1a0a4c37 Add asserts on macOS/Windows so that they can't be anything but default
...for now?
2020-12-21 13:44:01 +00:00
Joe Rickerby 27f1a4eafc Use 'latest' for CI 2020-12-21 13:42:55 +00:00
Joe RickerbyandHenry Schreiner 91800e4739 Update .github/workflows/test.yml
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2020-12-21 11:31:22 +00:00
Joe Rickerby 0ca294e539 Add separate runner for emulation tests 2020-12-21 11:11:37 +00:00
Joe Rickerby 5aa85e815d Add integration test for emulation 2020-12-21 11:06:25 +00:00
Joe Rickerby 7c86223ff8 Add platform-specific arch option unit test 2020-12-21 11:05:19 +00:00
Joe Rickerby f73b6083d5 Add unit test for the option parsing 2020-12-21 11:00:33 +00:00
Joe Rickerby 0c9af0357b Add platform-specific CIBW_ARCHS options.
Remove 'auto' as a possible Architecture enum value. This is resolved
at option parse time.
2020-12-20 19:42:28 +00:00
Henry Schreiner 26b7b72d5e fix: drop printout 2020-12-18 14:39:27 -05:00
Henry Schreiner 0d29bf8dae refactor: --archs, CIBW_ARCHS, "auto"
Using `--archs` for the flag, comma separated, also accepting CIBW_ARCHS.
Supports "auto" as the default that can also expand, matching
CIBW_PLATFORM.
2020-12-18 12:30:02 -05:00
Pavel Savchenko ec99c01b2f Allow architecture selection 2020-12-16 23:20:10 +00:00
Pavel Savchenko 90a14b9dd2 fixup! Support docker qemu emulation in any linux env 2020-12-16 22:19:07 +00:00
Pavel Savchenko 76fe472638 Support docker qemu emulation in any linux env
- currently just prints out envs
2020-12-12 21:18:19 +00:00
88 changed files with 1749 additions and 546 deletions
+1 -1
View File
@@ -4,6 +4,6 @@ set -o xtrace
$PYTHON --version
$PYTHON -m pip --version
$PYTHON -m virtualenv -p $PYTHON venv
venv/bin/python -m pip install -r requirements-dev.txt
venv/bin/python -m pip install -e ".[dev]"
venv/bin/python -m pip freeze
venv/bin/python --version
+23 -2
View File
@@ -24,7 +24,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ['3.7']
timeout-minutes: 180
steps:
@@ -36,7 +36,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
python -m pip install -e ".[dev]"
- name: Install Visual C++ for Python 2.7
if: runner.os == 'Windows'
@@ -55,3 +55,24 @@ jobs:
- name: Test cibuildwheel
run: |
python ./bin/run_tests.py
test-emulated:
name: Test emulated cibuildwheel using qemu
runs-on: ubuntu-latest
timeout-minutes: 180
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Run the emulation tests
run: |
pytest --run-emulation test/test_emulation.py
+4 -2
View File
@@ -17,9 +17,11 @@ jobs:
python-version: 3.9
architecture: x64
- name: Install dependencies
run: python -m pip install requests pip-tools
- name: Run update
run: python -m pip install ".[dev]"
- name: "Run update: dependencies"
run: python ./bin/update_dependencies.py
- name: "Run update: python configs"
run: python ./bin/update_pythons.py --force
- name: Create Pull Request
if: github.ref == 'refs/heads/master'
uses: peter-evans/create-pull-request@v3
+1 -1
View File
@@ -11,5 +11,5 @@ linux:
DOCKER_TLS_CERTDIR: ""
script:
- curl -sSL https://get.docker.com/ | sh
- python -m pip install -r requirements-dev.txt
- python -m pip install -e ".[dev]"
- python ./bin/run_tests.py
+29 -9
View File
@@ -1,13 +1,7 @@
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
exclude: cibuildwheel/resources/
additional_dependencies: [flake8-bugbear]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v3.4.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
@@ -17,9 +11,35 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
files: ^bin/update_pythons.py$
args: ["--line-length=120"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
rev: v0.790
hooks:
- id: mypy
files: ^(cibuildwheel/|test/|bin/projects.py)
files: ^(cibuildwheel/|test/|bin/projects.py|bin/update_pythons.py|unit_test/)
pass_filenames: false
additional_dependencies: [packaging, click]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
- id: pyupgrade
args: ["--py36-plus"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
exclude: cibuildwheel/resources/
additional_dependencies: [flake8-bugbear]
+4 -1
View File
@@ -8,4 +8,7 @@ mkdocs:
python:
version: 3.7
install:
- requirements: requirements-dev.txt
- method: pip
path: .
extra_requirements:
- dev
+1 -1
View File
@@ -54,6 +54,6 @@ jobs:
# must repeat the s390x job above exactly to match
- *linux_s390x_36
install: $PYTHON -m pip install -r requirements-dev.txt pytest-custom-exit-code
install: $PYTHON -m pip install -e ".[dev]" pytest-custom-exit-code
script: $PYTHON ./bin/run_tests.py
+109 -47
View File
@@ -9,7 +9,7 @@ cibuildwheel
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 GitHub Actions, Azure Pipelines, Travis CI, AppVeyor, and CircleCI - and it builds and tests your wheels across all of your platforms.
`cibuildwheel` is here to help. `cibuildwheel` runs on your CI server - currently it supports GitHub Actions, Azure Pipelines, Travis CI, AppVeyor, CircleCI, and GitLab CI - and it builds and tests your wheels across all of your platforms.
What does it do?
@@ -31,21 +31,22 @@ What does it do?
<sup>² Only supported on Travis</sup><br>
<sup>³ Beta support until Travis CI fixes <a href="https://travis-ci.community/t/no-space-left-on-device-for-system-z/5954/11">a bug</a></sup><br>
- Builds manylinux, macOS and Windows wheels for CPython and PyPy using Azure Pipelines, Travis CI, AppVeyor, and CircleCI
- Builds manylinux, macOS, and Windows wheels for CPython and PyPy
- Works on GitHub Actions, Azure Pipelines, Travis CI, AppVeyor, CircleCI, and GitLab CI
- 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 on **Travis CI**, **Azure Pipelines**, **AppVeyor**, **GitHub Actions**, **CircleCI**, and **Gitlab CI**. Check the table below for supported platforms on each service:
`cibuildwheel` runs inside a CI service. Supported platforms depend on which service you're using:
| | Linux | macOS | Windows | Linux ARM |
|-----------------|-------|-------|---------|--------------|
| GitHub Actions | ✅ | ✅ | ✅ | ✴️¹ |
| Azure Pipelines | ✅ | ✅ | ✅ | ✴️¹ |
| Travis CI | ✅ | ✅ | ✅ | ✅ |
| AppVeyor | ✅ | ✅ | ✅ | |
| GitHub Actions | ✅ | ✅ | ✅ | ✴️¹ |
| CircleCI | ✅ | ✅ | | |
| Gitlab CI | ✅ | | | |
@@ -80,7 +81,7 @@ jobs:
name: Install Python
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.7.3
run: python -m pip install cibuildwheel==1.8.0
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
@@ -92,7 +93,7 @@ jobs:
path: ./wheelhouse/*.whl
```
For more information, including building on Python 2, PyPI deployment, and the use of other CI services like Travis CI, Appveyor, Azure Pipelines, or CircleCI, check out the [documentation](https://cibuildwheel.readthedocs.org) and the [examples](https://github.com/joerick/cibuildwheel/tree/master/examples).
For more information, including building on Python 2, PyPI deployment, and the use of other CI services, check out the [documentation](https://cibuildwheel.readthedocs.org) and the [examples](https://github.com/joerick/cibuildwheel/tree/master/examples).
Options
-------
@@ -101,6 +102,7 @@ Options
|---|--------|-------------|
| **Build selection** | [`CIBW_PLATFORM`](https://cibuildwheel.readthedocs.io/en/stable/options/#platform) | Override the auto-detected target platform |
| | [`CIBW_BUILD`](https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip) <br> [`CIBW_SKIP`](https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip) | Choose the Python versions to build |
| | [`CIBW_ARCHS_LINUX`](https://cibuildwheel.readthedocs.io/en/stable/options/#archs) | Build non-native architectures |
| **Build customization** | [`CIBW_ENVIRONMENT`](https://cibuildwheel.readthedocs.io/en/stable/options/#environment) | Set environment variables needed during the build |
| | [`CIBW_BEFORE_ALL`](https://cibuildwheel.readthedocs.io/en/stable/options/#before-all) | Execute a shell command on the build system before any wheels are built. |
| | [`CIBW_BEFORE_BUILD`](https://cibuildwheel.readthedocs.io/en/stable/options/#before-build) | Execute a shell command preparing each wheel's build |
@@ -111,6 +113,7 @@ Options
| | [`CIBW_BEFORE_TEST`](https://cibuildwheel.readthedocs.io/en/stable/options/#before-test) | Execute a shell command before testing each wheel |
| | [`CIBW_TEST_REQUIRES`](https://cibuildwheel.readthedocs.io/en/stable/options/#test-requires) | Install Python dependencies before running the tests |
| | [`CIBW_TEST_EXTRAS`](https://cibuildwheel.readthedocs.io/en/stable/options/#test-extras) | Install your wheel for testing using extras_require |
| | [`CIBW_TEST_SKIP`](https://cibuildwheel.readthedocs.io/en/stable/options/#test-skip) | Skip running tests on some builds |
| **Other** | [`CIBW_BUILD_VERBOSITY`](https://cibuildwheel.readthedocs.io/en/stable/options/#build-verbosity) | Increase/decrease the output of pip wheel |
@@ -129,17 +132,21 @@ Here are some repos that use cibuildwheel.
|-----------------------------------|----|----|:------|
| [scikit-learn][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The machine learning library. A complex but clean config using many of cibuildwheel's features to build a large project with Cython and C++ extensions. |
| [Matplotlib][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The venerable Matplotlib, a Python library with C++ portions |
| [MyPy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | MyPyC, the compiled component of MyPy. |
| [psutil][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Cross-platform lib for process and system monitoring in Python |
| [twisted-iocpsupport][] | ![github icon][] | ![windows icon][] | A submodule of Twisted that hooks into native C APIs using Cython. |
| [scikit-image][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Image processing library. Uses cibuildwheel to build and test a project that uses Cython with platform-native code. |
| [twisted-iocpsupport][] | ![github icon][] | ![windows icon][] | A submodule of Twisted that hooks into native C APIs using Cython. |
| [websockets][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | Library for building WebSocket servers and clients. Mostly written in Python, with a small C 'speedups' extension module. |
| [pyzmq][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python bindings for zeromq, the networking library. Uses Cython and CFFI. |
| [aiortc][] | ![github icon][] | ![apple icon][] ![linux icon][] | WebRTC and ORTC implementation for Python using asyncio. |
| [numexpr][] | ![github icon][] ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Fast numerical array expression evaluator for Python, NumPy, PyTables, pandas, bcolz and more |
| [h5py][] | ![azurepipelines icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | HDF5 for Python -- The h5py package is a Pythonic interface to the HDF5 binary data format. |
| [coverage.py][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The coverage tool for Python |
| [River][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | 🌊 Online machine learning in Python |
| [PyAV][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Pythonic bindings for FFmpeg's libraries. |
| [Dependency Injector][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Dependency injection framework for Python, uses Windows TravisCI |
| [PyTables][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python package to manage extremely large amounts of data |
| [ruptures][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Extensive Cython + NumPy [pyproject.toml](https://github.com/deepcharles/ruptures/blob/master/pyproject.toml) example. |
| [aioquic][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | QUIC and HTTP/3 implementation in Python |
| [google neuroglancer][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | WebGL-based viewer for volumetric data |
| [AutoPy][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Includes a Windows Travis build. |
@@ -148,10 +155,15 @@ Here are some repos that use cibuildwheel.
| [python-rapidjson][] | ![travisci icon][] ![gitlab icon][] ![appveyor icon][] | ![windows icon][] ![linux icon][] | Python wrapper around rapidjson |
| [Rtree][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Rtree: spatial index for Python GIS ¶ |
| [KDEpy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Kernel Density Estimation in Python |
| [pybind11 python_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a Python-based build system |
| [cyvcf2][] | ![github icon][] | ![apple icon][] ![linux icon][] | cython + htslib == fast VCF and BCF processing |
| [pybind11 cmake_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a CMake-based build system |
| [pybind11 python_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Example pybind11 module built with a Python-based build system |
| [dd-trace-py][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Uses custom alternate arch emulation on GitHub |
| [iminuit][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Jupyter-friendly Python interface for C++ MINUIT2 |
| [jq.py][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | Python bindings for jq |
| [matrixprofile][] | ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A Python 3 library making time series data mining tasks, utilizing matrix profile algorithms, accessible to everyone. |
| [CTranslate2][] | ![github icon][] | ![apple icon][] ![linux icon][] | Includes libraries from the [Intel oneAPI toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit.html). The Linux wheels also include CUDA libraries for GPU execution. |
| [Tokenizer][] | ![github icon][] ![travisci icon][] | ![apple icon][] ![linux icon][] | Fast and customizable text tokenization library with BPE and SentencePiece support |
| [bx-python][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | A library that includes Cython extensions. |
| [boost-histogram][] | ![github icon][] ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Supports full range of wheels, including PyPy and alternate archs. |
| [pybase64][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Fast Base64 encoding/decoding in Python |
@@ -161,22 +173,27 @@ Here are some repos that use cibuildwheel.
| [numpythia][] | ![github icon][] | ![apple icon][] ![linux icon][] | The interface between PYTHIA and NumPy |
| [fathon][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | python package for DFA (Detrended Fluctuation Analysis) and related algorithms |
| [pyinstrument_cext][] | ![travisci icon][] ![appveyor icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | A simple C extension, without external dependencies |
| [Imagecodecs (fork)][] | ![azurepipelines icon][] | ![apple icon][] ![linux icon][] | Over 20 external dependencies in compiled libraries, custom docker image, `libomp`, `openblas` and `install_name_tool` for macOS. |
| [xmlstarlet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Python 3.6+ CFFI bindings with true MSVC build. |
| [pybind11 scikit_build_example][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | An example combining scikit-build and pybind11 |
[scikit-learn]: https://github.com/scikit-learn/scikit-learn
[Matplotlib]: https://github.com/matplotlib/matplotlib
[MyPy]: https://github.com/mypyc/mypy_mypyc-wheels
[psutil]: https://github.com/giampaolo/psutil
[twisted-iocpsupport]: https://github.com/twisted/twisted-iocpsupport
[scikit-image]: https://github.com/scikit-image/scikit-image
[twisted-iocpsupport]: https://github.com/twisted/twisted-iocpsupport
[websockets]: https://github.com/aaugustin/websockets
[pyzmq]: https://github.com/zeromq/pyzmq
[aiortc]: https://github.com/aiortc/aiortc
[numexpr]: https://github.com/pydata/numexpr
[h5py]: https://github.com/h5py/h5py
[coverage.py]: https://github.com/nedbat/coveragepy
[River]: https://github.com/online-ml/river
[PyAV]: https://github.com/PyAV-Org/PyAV
[Dependency Injector]: https://github.com/ets-labs/python-dependency-injector
[PyTables]: https://github.com/PyTables/PyTables
[ruptures]: https://github.com/deepcharles/ruptures
[aioquic]: https://github.com/aiortc/aioquic
[google neuroglancer]: https://github.com/google/neuroglancer
[AutoPy]: https://github.com/autopilot-rs/autopy
@@ -185,10 +202,15 @@ Here are some repos that use cibuildwheel.
[python-rapidjson]: https://github.com/python-rapidjson/python-rapidjson
[Rtree]: https://github.com/Toblerity/rtree
[KDEpy]: https://github.com/tommyod/KDEpy
[pybind11 python_example]: https://github.com/pybind/python_example
[cyvcf2]: https://github.com/brentp/cyvcf2
[pybind11 cmake_example]: https://github.com/pybind/cmake_example
[pybind11 python_example]: https://github.com/pybind/python_example
[dd-trace-py]: https://github.com/DataDog/dd-trace-py
[iminuit]: https://github.com/scikit-hep/iminuit
[jq.py]: https://github.com/mwilliamson/jq.py
[matrixprofile]: https://github.com/matrix-profile-foundation/matrixprofile
[CTranslate2]: https://github.com/OpenNMT/CTranslate2
[Tokenizer]: https://github.com/OpenNMT/Tokenizer
[bx-python]: https://github.com/bxlab/bx-python
[boost-histogram]: https://github.com/scikit-hep/boost-histogram
[pybase64]: https://github.com/mayeut/pybase64
@@ -198,6 +220,7 @@ Here are some repos that use cibuildwheel.
[numpythia]: https://github.com/scikit-hep/numpythia
[fathon]: https://github.com/stfbnc/fathon
[pyinstrument_cext]: https://github.com/joerick/pyinstrument_cext
[Imagecodecs (fork)]: https://github.com/czaki/imagecodecs_build
[xmlstarlet]: https://github.com/dimitern/xmlstarlet
[pybind11 scikit_build_example]: https://github.com/pybind/scikit_build_example
@@ -211,46 +234,56 @@ Here are some repos that use cibuildwheel.
[apple icon]: docs/data/readme_icons/apple.svg
[linux icon]: docs/data/readme_icons/linux.svg
<!-- scikit-learn: 43477, last pushed 0 days ago -->
<!-- Matplotlib: 12823, last pushed 0 days ago -->
<!-- psutil: 6887, last pushed 0 days ago -->
<!-- twisted-iocpsupport: 4114, last pushed 2 days ago -->
<!-- scikit-image: 4104, last pushed 0 days ago -->
<!-- websockets: 3089, last pushed 10 days ago -->
<!-- pyzmq: 2654, last pushed 20 days ago -->
<!-- aiortc: 2073, last pushed 7 days ago -->
<!-- h5py: 1455, last pushed 12 days ago -->
<!-- coverage.py: 1441, last pushed 3 days ago -->
<!-- River: 1219, last pushed 0 days ago -->
<!-- PyAV: 1114, last pushed 14 days ago -->
<!-- Dependency Injector: 1030, last pushed 0 days ago -->
<!-- aioquic: 552, last pushed 49 days ago -->
<!-- google neuroglancer: 550, last pushed 7 days ago -->
<!-- AutoPy: 507, last pushed 105 days ago -->
<!-- pikepdf: 487, last pushed 0 days ago -->
<!-- Parselmouth: 433, last pushed 26 days ago -->
<!-- python-rapidjson: 407, last pushed 10 days ago -->
<!-- Rtree: 378, last pushed 0 days ago -->
<!-- KDEpy: 230, last pushed 9 days ago -->
<!-- pybind11 python_example: 221, last pushed 44 days ago -->
<!-- pybind11 cmake_example: 219, last pushed 7 days ago -->
<!-- iminuit: 166, last pushed 0 days ago -->
<!-- jq.py: 138, last pushed 73 days ago -->
<!-- bx-python: 94, last pushed 1 days ago -->
<!-- boost-histogram: 63, last pushed 0 days ago -->
<!-- pybase64: 52, last pushed 2 days ago -->
<!-- TgCrypto: 49, last pushed 36 days ago -->
<!-- etebase-py: 40, last pushed 3 days ago -->
<!-- pyjet: 27, last pushed 29 days ago -->
<!-- numpythia: 23, last pushed 28 days ago -->
<!-- fathon: 18, last pushed 1 days ago -->
<!-- pyinstrument_cext: 10, last pushed 29 days ago -->
<!-- xmlstarlet: 7, last pushed 0 days ago -->
<!-- pybind11 scikit_build_example: 0, last pushed 42 days ago -->
<!-- scikit-learn: 43800, last pushed 0 days ago -->
<!-- Matplotlib: 12963, last pushed 0 days ago -->
<!-- MyPy: 9770, last pushed 0 days ago -->
<!-- psutil: 6990, last pushed 5 days ago -->
<!-- scikit-image: 4143, last pushed 0 days ago -->
<!-- twisted-iocpsupport: 4140, last pushed 7 days ago -->
<!-- websockets: 3146, last pushed 9 days ago -->
<!-- pyzmq: 2675, last pushed 1 days ago -->
<!-- aiortc: 2113, last pushed 7 days ago -->
<!-- numexpr: 1512, last pushed 16 days ago -->
<!-- h5py: 1474, last pushed 2 days ago -->
<!-- coverage.py: 1471, last pushed 2 days ago -->
<!-- River: 1296, last pushed 0 days ago -->
<!-- PyAV: 1142, last pushed 13 days ago -->
<!-- Dependency Injector: 1070, last pushed 0 days ago -->
<!-- PyTables: 1001, last pushed 6 days ago -->
<!-- ruptures: 589, last pushed 3 days ago -->
<!-- aioquic: 571, last pushed 78 days ago -->
<!-- google neuroglancer: 555, last pushed 0 days ago -->
<!-- AutoPy: 517, last pushed 134 days ago -->
<!-- pikepdf: 517, last pushed 5 days ago -->
<!-- Parselmouth: 450, last pushed 1 days ago -->
<!-- python-rapidjson: 410, last pushed 39 days ago -->
<!-- Rtree: 387, last pushed 28 days ago -->
<!-- KDEpy: 235, last pushed 37 days ago -->
<!-- cyvcf2: 233, last pushed 0 days ago -->
<!-- pybind11 cmake_example: 226, last pushed 35 days ago -->
<!-- pybind11 python_example: 224, last pushed 73 days ago -->
<!-- dd-trace-py: 206, last pushed 0 days ago -->
<!-- iminuit: 166, last pushed 25 days ago -->
<!-- jq.py: 140, last pushed 102 days ago -->
<!-- matrixprofile: 124, last pushed 2 days ago -->
<!-- CTranslate2: 123, last pushed 0 days ago -->
<!-- Tokenizer: 115, last pushed 3 days ago -->
<!-- bx-python: 95, last pushed 30 days ago -->
<!-- boost-histogram: 66, last pushed 0 days ago -->
<!-- pybase64: 54, last pushed 0 days ago -->
<!-- TgCrypto: 51, last pushed 65 days ago -->
<!-- etebase-py: 40, last pushed 17 days ago -->
<!-- pyjet: 27, last pushed 3 days ago -->
<!-- numpythia: 24, last pushed 9 days ago -->
<!-- fathon: 20, last pushed 4 days ago -->
<!-- pyinstrument_cext: 10, last pushed 57 days ago -->
<!-- Imagecodecs (fork): 10, last pushed 7 days ago -->
<!-- xmlstarlet: 7, last pushed 2 days ago -->
<!-- pybind11 scikit_build_example: 2, last pushed 18 days ago -->
<!-- END bin/projects.py -->
> Add your repo here! Send a PR, adding your information to `docs/data/projects.yml`.
> Add your repo here! Let us know on [GitHub Discussions](https://github.com/joerick/cibuildwheel/discussions/485), or send a PR, adding your information to `docs/data/projects.yml`.
>
> <sup>I'd like to include notes here to indicate why an example might be interesting to cibuildwheel users - the styles/technologies/techniques used in each. Please include that in future additions!</sup>
@@ -270,6 +303,33 @@ Changelog
<!--changelog-start-->
### 1.8.0
_22 January 2021_
- 🌟 Added support for emulated builds! You can now build manylinux wheels on
ARM64`aarch64`, as well as `ppc64le` and 's390x'. To build under emulation,
register QEMU via binfmt_misc and set the
[`CIBW_ARCHS_LINUX`](https://cibuildwheel.readthedocs.io/en/latest/options/#archs)
option to the architectures you want to run. See
[this FAQ entry](https://cibuildwheel.readthedocs.io/en/latest/faq/#emulation)
for more information. (#482)
- ✨ Added `CIBW_TEST_SKIP` option. This allows you to choose certain builds
whose tests you'd like to skip. This might be useful when running a slow
test suite under emulation, for example. (#537)
- ✨ Added `curly-{brace,bracket,paren}` style globbing to `CIBW_BUILD` and
`CIBW_SKIP`. This gives more expressivity, letting you do things like
`CIBW_BUILD=cp39-manylinux_{aarch64,ppc64le}`. (#527)
- 🛠 cibuildwheel will now exit with an error if it's called with options that
skip all builds on a platform. This feature can be disabled by adding
`--allow-empty` on the command line. (#545)
### 1.7.4
_2 January 2021_
- 🐛 Fix the PyPy virtualenv patch to work on macOS 10.14 (#506)
### 1.7.3
_1 January 2021_
@@ -728,6 +788,8 @@ Massive props also to-
- @zfrenchee for [help debugging many issues](https://github.com/joerick/cibuildwheel/issues/2)
- @lelit for some great bug reports and [contributions](https://github.com/joerick/cibuildwheel/pull/73)
- @mayeut for a [phenomenal PR](https://github.com/joerick/cibuildwheel/pull/71) patching Python itself for better compatibility!
- @czaki for being a super-contributor over many PRs and helping out with countless issues!
- @mattip for his help with adding PyPy support to cibuildwheel
See also
========
+6 -4
View File
@@ -19,8 +19,10 @@ runs:
# This needs powershell-core because github.action path is a Windows-style
# path on Windows. Powershell-core understands both types of paths.
- run: python -m pip install ${{ github.action_path }}
- run: >
pipx run
--spec ${{ github.action_path }}
cibuildwheel
${{ inputs.package-dir }}
--output-dir ${{ inputs.output-dir }}
shell: pwsh
- run: python -m cibuildwheel ${{ inputs.package-dir }} --output-dir ${{ inputs.output-dir }}
shell: bash
+1 -1
View File
@@ -19,7 +19,7 @@ init:
$env:PYTEST_ADDOPTS='-k "unit_test or test_0_basic" --suppress-no-test-exit-code'
}
install: python -m pip install -r requirements-dev.txt pytest-custom-exit-code
install: python -m pip install -e ".[dev]" pytest-custom-exit-code
# the '-u' flag is required so the output is in the correct order.
# See https://github.com/joerick/cibuildwheel/pull/24 for more info.
+4 -4
View File
@@ -6,7 +6,7 @@ jobs:
inputs:
versionSpec: '3.8'
- bash: |
python -m pip install -r requirements-dev.txt pytest-azurepipelines
python -m pip install -e ".[dev]" pytest-azurepipelines
python ./bin/run_tests.py
- job: macos_38
@@ -16,7 +16,7 @@ jobs:
inputs:
versionSpec: '3.8'
- bash: |
python -m pip install -r requirements-dev.txt pytest-azurepipelines
python -m pip install -e ".[dev]" pytest-azurepipelines
python ./bin/run_tests.py
- job: windows_36
@@ -29,7 +29,7 @@ jobs:
- script: choco install vcpython27 -f -y
displayName: Install Visual C++ for Python 2.7
- bash: |
python -m pip install -r requirements-dev.txt pytest-azurepipelines
python -m pip install -e ".[dev]" pytest-azurepipelines
python ./bin/run_tests.py
- job: windows_38
@@ -42,5 +42,5 @@ jobs:
- script: choco install vcpython27 -f -y
displayName: Install Visual C++ for Python 2.7
- bash: |
python -m pip install -r requirements-dev.txt pytest-azurepipelines
python -m pip install -e ".[dev]" pytest-azurepipelines
python ./bin/run_tests.py
+20 -14
View File
@@ -1,13 +1,17 @@
#!/usr/bin/env python3
import click
from pathlib import Path
import os
import cibuildwheel
from packaging.version import Version, InvalidVersion
import subprocess
import glob
import os
import subprocess
import sys
import urllib.parse
from pathlib import Path
import click
from packaging.version import InvalidVersion, Version
import cibuildwheel
config = [
# file path, version find/replace format
@@ -17,10 +21,12 @@ config = [
('docs/faq.md', "cibuildwheel@v{}"),
('docs/setup.md', "cibuildwheel@v{}"),
('examples/*', "cibuildwheel=={}"),
('setup.py', "version='{}'"),
('setup.cfg', "version = {}"),
]
# This file requires Python 3.7
# Setting -> None will cause MyPy to notice this.
@click.command()
def bump_version():
current_version = cibuildwheel.__version__
@@ -47,7 +53,7 @@ def bump_version():
if repo_has_uncommitted_changes:
print('error: Uncommitted changes detected.')
exit(1)
sys.exit(1)
print( 'Current version:', current_version) # noqa
new_version = input(' New version: ').strip()
@@ -57,7 +63,7 @@ def bump_version():
except InvalidVersion:
print("error: This version doesn't conform to PEP440")
print(' https://www.python.org/dev/peps/pep-0440/')
exit(1)
sys.exit(1)
actions = []
@@ -66,7 +72,7 @@ def bump_version():
if not paths:
print(f'error: Pattern {path_pattern} didnt match any files')
exit(1)
sys.exit(1)
find_pattern = version_pattern.format(current_version)
replace_pattern = version_pattern.format(new_version)
@@ -81,8 +87,8 @@ def bump_version():
)
if not found_at_least_one_file_needing_update:
print('error: Didnt find any occurences of “{}” in “{}'.format(find_pattern, path_pattern))
exit(1)
print(f'error: Didnt find any occurrences of “{find_pattern}” in “{path_pattern}')
sys.exit(1)
print()
print("Here's the plan:")
@@ -94,13 +100,13 @@ def bump_version():
red="\u001b[31m", green="\u001b[32m", off="\u001b[0m"
))
print('Then commit, and tag as v{}'.format(new_version))
print(f'Then commit, and tag as v{new_version}')
answer = input('Proceed? [y/N] ').strip()
if answer != 'y':
print('Aborted')
exit(1)
sys.exit(1)
for path, find, replace in actions:
contents = path.read_text(encoding='utf8')
+3 -2
View File
@@ -1,12 +1,13 @@
#!/usr/bin/env python3
import os
import sys
import textwrap
import time
from pathlib import Path
from subprocess import run
import click
import textwrap
def shell(cmd, **kwargs):
@@ -26,7 +27,7 @@ def main():
if git_repo_has_changes():
print('Your git repo has uncommitted changes. Commit or stash before continuing.')
exit(1)
sys.exit(1)
previous_branch = shell('git rev-parse --abbrev-ref HEAD',
check=True,
+12 -8
View File
@@ -11,17 +11,16 @@ Suggested usage:
import builtins
import functools
import urllib.request
import xml.dom.minidom
from datetime import datetime
from io import StringIO
from typing import Dict, Any, List, Optional, TextIO
from pathlib import Path
from typing import Any, Dict, List, Optional, TextIO
import click
import yaml
from github import Github
import urllib.request
import xml.dom.minidom
from pathlib import Path
from github import Github, GithubException
ICONS = (
"appveyor",
@@ -54,7 +53,12 @@ class Project:
self.online = github is not None
if github is not None:
repo = github.get_repo(self.stars_repo)
try:
repo = github.get_repo(self.stars_repo)
except GithubException:
print(f"Broken: {self.stars_repo}")
raise
self.num_stars = repo.stargazers_count
self.pushed_at = repo.pushed_at
if not self.notes:
@@ -168,7 +172,7 @@ def str_projects(
return io.getvalue()
@click.command()
@click.command(help="Try ./bin/projects.py docs/data/projects.yml --readme README.md")
@click.argument("input", type=click.File("r"))
@click.option("--online/--no-online", default=True, help="Get info from GitHub")
@click.option("--auth", help="GitHub authentication token")
+44 -19
View File
@@ -1,16 +1,18 @@
#!/usr/bin/env python3
import os
from pathlib import Path
import shutil
from subprocess import run
import sys
import textwrap
import time
import click
from collections import namedtuple
from glob import glob
from pathlib import Path
from subprocess import run
from urllib.parse import quote
import click
def shell(cmd, **kwargs):
return run([cmd], shell=True, **kwargs)
@@ -30,52 +32,73 @@ def generate_basic_project(path):
project.generate(path)
CIService = namedtuple('CIService', 'name src_config_path dst_config_path badge_md')
CIService = namedtuple('CIService', 'name dst_config_path badge_md')
services = [
CIService(
name='appveyor',
src_config_path='examples/appveyor-minimal.yml',
dst_config_path='appveyor.yml',
badge_md='[![Build status](https://ci.appveyor.com/api/projects/status/wbsgxshp05tt1tif/branch/{branch}?svg=true)](https://ci.appveyor.com/project/joerick/cibuildwheel/branch/{branch})',
),
CIService(
name='azure-pipelines',
src_config_path='examples/azure-pipelines-minimal.yml',
dst_config_path='azure-pipelines.yml',
badge_md='[![Build Status](https://dev.azure.com/joerick0429/cibuildwheel/_apis/build/status/joerick.cibuildwheel?branchName={branch})](https://dev.azure.com/joerick0429/cibuildwheel/_build/latest?definitionId=2&branchName={branch})',
),
CIService(
name='circle-ci',
src_config_path='examples/circleci-minimal.yml',
name='circleci',
dst_config_path='.circleci/config.yml',
badge_md='[![CircleCI](https://circleci.com/gh/joerick/cibuildwheel/tree/{branch_escaped}.svg?style=svg)](https://circleci.com/gh/joerick/cibuildwheel/tree/{branch})',
),
CIService(
name='github',
src_config_path='examples/github-minimal.yml',
dst_config_path='.github/workflows/example.yml',
badge_md='[![Build](https://github.com/joerick/cibuildwheel/workflows/Build/badge.svg?branch={branch})](https://github.com/joerick/cibuildwheel/actions)',
),
CIService(
name='travis-ci',
src_config_path='examples/travis-ci-minimal.yml',
dst_config_path='.travis.yml',
badge_md='[![Build Status](https://travis-ci.org/joerick/cibuildwheel.svg?branch={branch})](https://travis-ci.org/joerick/cibuildwheel)',
),
CIService(
name='gitlab',
src_config_path='examples/gitlab-minimal.yml',
dst_config_path='.gitlab-ci.yml',
badge_md='[![Gitlab](https://gitlab.com/joerick/cibuildwheel/badges/{branch}/pipeline.svg)](https://gitlab.com/joerick/cibuildwheel/-/commits/{branch})'
),
]
def ci_service_for_config_file(config_file):
service_name = Path(config_file).name.rsplit('-', 1)[0]
for service in services:
if service.name == service_name:
return service
raise ValueError(f'unknown ci service for config file {config_file}')
@click.command()
def run_example_ci_configs():
@click.argument('config_files', nargs=-1, type=click.Path())
def run_example_ci_configs(config_files=None):
'''
Test the example configs. If no files are specified, will test
examples/*-minimal.yml
'''
if len(config_files) == 0:
config_files = glob('examples/*-minimal.yml')
# check each CI service has at most 1 config file
configs_by_service = {}
for config_file in config_files:
service = ci_service_for_config_file(config_file)
if service.name in configs_by_service:
raise Exception('You cannot specify more than one config per CI service')
configs_by_service[service.name] = config_file
if git_repo_has_changes():
print('Your git repo has uncommitted changes. Commit or stash before continuing.')
exit(1)
sys.exit(1)
previous_branch = shell('git rev-parse --abbrev-ref HEAD',
check=True,
@@ -91,18 +114,19 @@ def run_example_ci_configs():
example_project = Path('example_root')
generate_basic_project(example_project)
for service in services:
src_config_file = Path(service.src_config_path)
for config_file in config_files:
service = ci_service_for_config_file(config_file)
src_config_file = Path(config_file)
dst_config_file = example_project / service.dst_config_path
dst_config_file.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(src_config_file, dst_config_file)
run(['git', 'add', example_project], check=True)
run(['git', 'commit', '-m', textwrap.dedent(f'''
run(['git', 'commit', '--no-verify', '-m', textwrap.dedent(f'''
Test example minimal configs
Testing files: {[s.src_config_path for s in services]}
Testing files: {config_files}
Generated from branch: {previous_branch}
Time: {timestamp}
''')], check=True)
@@ -116,9 +140,10 @@ def run_example_ci_configs():
print('> ')
print('> | Service | Config | Status |')
print('> |---|---|---|')
for service in services:
for config_file in config_files:
service = ci_service_for_config_file(config_file)
badge = service.badge_md.format(branch=branch_name, branch_escaped=quote(branch_name, safe=''))
print(f'> | {service.name} | `{service.src_config_path}` | {badge} |')
print(f'> | {service.name} | `{config_file}` | {badge} |')
print('> ')
print('> Generated by `bin/run_example_ci_config.py`')
print()
+2 -2
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
import argparse
import tempfile
from pathlib import Path
@@ -22,4 +22,4 @@ if __name__ == '__main__':
options.project_python_path, project_dir
], check=True)
exit(subprocess.run(['cibuildwheel'], cwd=project_dir).returncode)
sys.exit(subprocess.run(['cibuildwheel'], cwd=project_dir).returncode)
+3 -3
View File
@@ -28,8 +28,8 @@ if '--no-docker' in sys.argv:
'--output-file', f'cibuildwheel/resources/constraints-python{python_version}.txt'
])
else:
image = 'quay.io/pypa/manylinux2010_x86_64:latest'
subprocess.check_call(['docker', 'pull', image])
image_runner = 'quay.io/pypa/manylinux2010_x86_64:latest'
subprocess.check_call(['docker', 'pull', image_runner])
for python_version in PYTHON_VERSIONS:
abi_flags = '' if int(python_version) >= 38 else 'm'
python_path = f'/opt/python/cp{python_version}-cp{python_version}{abi_flags}/bin/'
@@ -37,7 +37,7 @@ else:
'docker', 'run', '--rm',
'-e', 'CUSTOM_COMPILE_COMMAND',
'-v', f'{os.getcwd()}:/volume',
'--workdir', '/volume', image,
'--workdir', '/volume', image_runner,
'bash', '-c',
f'{python_path}pip install pip-tools &&'
f'{python_path}pip-compile --allow-unsafe --upgrade '
+310
View File
@@ -0,0 +1,310 @@
#!/usr/bin/env python3
import copy
import difflib
import logging
from pathlib import Path
from typing import Dict, Optional, Union
import click
import requests
import rich
import toml
from packaging.specifiers import Specifier
from packaging.version import Version
from rich.logging import RichHandler
from rich.syntax import Syntax
from cibuildwheel.extra import InlineArrayDictEncoder
from cibuildwheel.typing import Final, Literal, TypedDict
log = logging.getLogger("cibw")
# Looking up the dir instead of using utils.resources_dir
# since we want to write to it.
DIR: Final[Path] = Path(__file__).parent.parent.resolve()
RESOURCES_DIR: Final[Path] = DIR / "cibuildwheel/resources"
ArchStr = Literal["32", "64"]
class ConfigWinCP(TypedDict):
identifier: str
version: str
arch: str
class ConfigWinPP(TypedDict):
identifier: str
version: str
arch: str
url: str
class ConfigMacOS(TypedDict):
identifier: str
version: str
url: str
AnyConfig = Union[ConfigWinCP, ConfigWinPP, ConfigMacOS]
# The following set of "Versions" classes allow the initial call to the APIs to
# be cached and reused in the `update_version_*` methods.
class WindowsVersions:
def __init__(self, arch_str: ArchStr) -> None:
response = requests.get("https://api.nuget.org/v3/index.json")
response.raise_for_status()
api_info = response.json()
for resource in api_info["resources"]:
if resource["@type"] == "PackageBaseAddress/3.0.0":
endpoint = resource["@id"]
ARCH_DICT = {"32": "win32", "64": "win_amd64"}
PACKAGE_DICT = {"32": "pythonx86", "64": "python"}
self.arch_str = arch_str
self.arch = ARCH_DICT[arch_str]
package = PACKAGE_DICT[arch_str]
response = requests.get(f"{endpoint}{package}/index.json")
response.raise_for_status()
cp_info = response.json()
versions = (Version(v) for v in cp_info["versions"])
self.versions = sorted(v for v in versions if not v.is_devrelease)
def update_version_windows(self, spec: Specifier) -> Optional[ConfigWinCP]:
versions = sorted(v for v in self.versions if spec.contains(v))
if not all(v.is_prerelease for v in versions):
versions = [v for v in versions if not v.is_prerelease]
log.debug(f"Windows {self.arch} {spec} has {', '.join(str(v) for v in versions)}")
if not versions:
return None
version = versions[-1]
identifier = f"cp{version.major}{version.minor}-{self.arch}"
result = ConfigWinCP(
identifier=identifier,
version=str(version),
arch=self.arch_str,
)
return result
class PyPyVersions:
def __init__(self, arch_str: ArchStr):
response = requests.get("https://downloads.python.org/pypy/versions.json")
response.raise_for_status()
releases = [r for r in response.json() if r["pypy_version"] != "nightly"]
for release in releases:
release["pypy_version"] = Version(release["pypy_version"])
release["python_version"] = Version(release["python_version"])
self.releases = [
r for r in releases if not r["pypy_version"].is_prerelease and not r["pypy_version"].is_devrelease
]
self.arch = arch_str
def update_version_windows(self, spec: Specifier) -> ConfigWinCP:
if self.arch != "32":
raise RuntimeError("64 bit releases not supported yet on Windows")
releases = [r for r in self.releases if spec.contains(r["python_version"])]
releases = sorted(releases, key=lambda r: r["pypy_version"])
if not releases:
raise RuntimeError(f"PyPy Win {self.arch} not found for {spec}! {self.releases}")
release = releases[-1]
version = release["python_version"]
identifier = f"pp{version.major}{version.minor}-win32"
(url,) = [rf["download_url"] for rf in release["files"] if "" in rf["platform"] == "win32"]
return ConfigWinPP(
identifier=identifier,
version=f"{version.major}.{version.minor}",
arch="32",
url=url,
)
def update_version_macos(self, spec: Specifier) -> ConfigMacOS:
if self.arch != "64":
raise RuntimeError("Other archs not supported yet on macOS")
releases = [r for r in self.releases if spec.contains(r["python_version"])]
releases = sorted(releases, key=lambda r: r["pypy_version"])
if not releases:
raise RuntimeError(f"PyPy macOS {self.arch} not found for {spec}!")
release = releases[-1]
version = release["python_version"]
identifier = f"pp{version.major}{version.minor}-macosx_x86_64"
(url,) = [
rf["download_url"] for rf in release["files"] if "" in rf["platform"] == "darwin" and rf["arch"] == "x64"
]
return ConfigMacOS(
identifier=identifier,
version=f"{version.major}.{version.minor}",
url=url,
)
class CPythonVersions:
def __init__(self, plat_arch: str, file_ident: str) -> None:
response = requests.get("https://www.python.org/api/v2/downloads/release/?is_published=true")
response.raise_for_status()
releases_info = response.json()
self.versions_dict: Dict[Version, int] = {}
for release in releases_info:
# Removing the prefix, Python 3.9 would use: release["name"].removeprefix("Python ")
version = Version(release["name"][7:])
if not version.is_prerelease and not version.is_devrelease:
uri = int(release["resource_uri"].rstrip("/").split("/")[-1])
self.versions_dict[version] = uri
self.file_ident = file_ident
self.plat_arch = plat_arch
def update_version_macos(self, spec: Specifier) -> Optional[ConfigMacOS]:
sorted_versions = sorted(v for v in self.versions_dict if spec.contains(v))
for version in reversed(sorted_versions):
# Find the first patch version that contains the requested file
uri = self.versions_dict[version]
response = requests.get(f"https://www.python.org/api/v2/downloads/release_file/?release={uri}")
response.raise_for_status()
file_info = response.json()
urls = [rf["url"] for rf in file_info if self.file_ident in rf["url"]]
if urls:
return ConfigMacOS(
identifier=f"cp{version.major}{version.minor}-{self.plat_arch}",
version=f"{version.major}.{version.minor}",
url=urls[0],
)
return None
# This is a universal interface to all the above Versions classes. Given an
# identifier, it updates a config dict.
class AllVersions:
def __init__(self) -> None:
self.windows_32 = WindowsVersions("32")
self.windows_64 = WindowsVersions("64")
self.windows_pypy = PyPyVersions("32")
self.macos_6 = CPythonVersions(plat_arch="macosx_x86_64", file_ident="macosx10.6.pkg")
self.macos_9 = CPythonVersions(plat_arch="macosx_x86_64", file_ident="macosx10.9.pkg")
self.macos_u2 = CPythonVersions(plat_arch="macosx_universal2", file_ident="macos11.0.pkg")
self.macos_pypy = PyPyVersions("64")
def update_config(self, config: Dict[str, str]) -> None:
identifier = config["identifier"]
version = Version(config["version"])
spec = Specifier(f"=={version.major}.{version.minor}.*")
log.info(f"Reading in '{identifier}' -> {spec} @ {version}")
orig_config = copy.copy(config)
config_update: Optional[AnyConfig]
# We need to use ** in update due to MyPy (probably a bug)
if "macosx_x86_64" in identifier:
if identifier.startswith("pp"):
config_update = self.macos_pypy.update_version_macos(spec)
else:
config_update = self.macos_9.update_version_macos(spec) or self.macos_6.update_version_macos(spec)
assert config_update is not None, f"MacOS {spec} not found!"
config.update(**config_update)
elif "win32" in identifier:
if identifier.startswith("pp"):
config.update(**self.windows_pypy.update_version_windows(spec))
else:
config_update = self.windows_32.update_version_windows(spec)
if config_update:
config.update(**config_update)
elif "win_amd64" in identifier:
config_update = self.windows_64.update_version_windows(spec)
if config_update:
config.update(**config_update)
if config != orig_config:
log.info(f" Updated {orig_config} to {config}")
@click.command()
@click.option("--force", is_flag=True)
@click.option("--level", default="INFO", type=click.Choice(["INFO", "DEBUG", "TRACE"], case_sensitive=False))
def update_pythons(force: bool, level: str) -> None:
logging.basicConfig(
level="INFO",
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(rich_tracebacks=True, markup=True)],
)
log.setLevel(level)
all_versions = AllVersions()
toml_file_path = RESOURCES_DIR / "build-platforms.toml"
original_toml = toml_file_path.read_text()
configs = toml.loads(original_toml)
for config in configs["windows"]["python_configurations"]:
all_versions.update_config(config)
for config in configs["macos"]["python_configurations"]:
all_versions.update_config(config)
result_toml = toml.dumps(configs, encoder=InlineArrayDictEncoder()) # type: ignore
rich.print() # spacer
if original_toml == result_toml:
rich.print("[green]Check complete, Python configurations unchanged.")
return
rich.print("Python configurations updated.")
rich.print("Changes:")
rich.print()
toml_relpath = toml_file_path.relative_to(DIR).as_posix()
diff_lines = difflib.unified_diff(
original_toml.splitlines(keepends=True),
result_toml.splitlines(keepends=True),
fromfile=toml_relpath,
tofile=toml_relpath,
)
rich.print(Syntax("".join(diff_lines), "diff", theme="ansi_light"))
rich.print()
if force:
toml_file_path.write_text(result_toml)
rich.print("[green]TOML file updated.")
else:
rich.print("[yellow]File left unchanged. Use --force flag to update.")
if __name__ == "__main__":
update_pythons()
+1 -1
View File
@@ -1 +1 @@
__version__ = '1.7.3'
__version__ = '1.8.0'
+72 -23
View File
@@ -5,21 +5,20 @@ import textwrap
import traceback
from configparser import ConfigParser
from pathlib import Path
from typing import Any, Dict, List, Optional, overload
from typing import Dict, List, Optional, Set, Union, overload
import cibuildwheel
import cibuildwheel.linux
import cibuildwheel.macos
import cibuildwheel.windows
from cibuildwheel.environment import (
EnvironmentParseError,
parse_environment,
)
from cibuildwheel.architecture import Architecture, allowed_architectures_check
from cibuildwheel.environment import EnvironmentParseError, parse_environment
from cibuildwheel.typing import PLATFORMS, PlatformName, assert_never
from cibuildwheel.util import (
BuildOptions,
BuildSelector,
DependencyConstraints,
TestSelector,
Unbuffered,
detect_ci_provider,
resources_dir,
@@ -49,6 +48,8 @@ def get_option_from_environment(option_name: str, platform: Optional[str] = None
def main() -> None:
platform: PlatformName
parser = argparse.ArgumentParser(
description='Build wheels for all the platforms.',
epilog='''
@@ -67,6 +68,17 @@ def main() -> None:
run in Windows, and it will build and test for all versions of
Python. Default: auto.
''')
parser.add_argument('--archs',
default=None,
help='''
Comma-separated list of CPU architectures to build for.
When set to 'auto', builds the architectures natively supported
on this machine. Set this option to build an architecture
via emulation, for example, using binfmt_misc and QEMU.
Default: auto.
Choices: auto, native, all, {}
'''.format(", ".join(a.name for a in Architecture)))
parser.add_argument('--output-dir',
default=os.environ.get('CIBW_OUTPUT_DIR', 'wheelhouse'),
help='Destination folder for the wheels.')
@@ -83,6 +95,9 @@ def main() -> None:
parser.add_argument('--print-build-identifiers',
action='store_true',
help='Print the build identifiers matched by the current invocation and exit.')
parser.add_argument('--allow-empty',
action='store_true',
help='Do not report an error code if the build does not match any wheels.')
args = parser.parse_args()
@@ -99,7 +114,7 @@ def main() -> None:
supported. You can run on your development machine or other CI providers using the
--platform argument. Check --help output for more information.
'''), file=sys.stderr)
exit(2)
sys.exit(2)
if sys.platform.startswith('linux'):
platform = 'linux'
elif sys.platform == 'darwin':
@@ -110,7 +125,11 @@ def main() -> None:
print('cibuildwheel: Unable to detect platform from "sys.platform" in a CI environment. You can run '
'cibuildwheel using the --platform argument. Check --help output for more information.',
file=sys.stderr)
exit(2)
sys.exit(2)
if platform not in PLATFORMS:
print(f'cibuildwheel: Unsupported platform: {platform}', file=sys.stderr)
sys.exit(2)
package_dir = Path(args.package_dir)
output_dir = Path(args.output_dir)
@@ -119,10 +138,13 @@ def main() -> None:
repair_command_default = 'auditwheel repair -w {dest_dir} {wheel}'
elif platform == 'macos':
repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}'
else:
elif platform == 'windows':
repair_command_default = ''
else:
assert_never(platform)
build_config, skip_config = os.environ.get('CIBW_BUILD', '*'), os.environ.get('CIBW_SKIP', '')
test_skip = os.environ.get('CIBW_TEST_SKIP', '')
environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='')
before_all = get_option_from_environment('CIBW_BEFORE_ALL', platform=platform, default='')
before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform)
@@ -134,14 +156,15 @@ def main() -> None:
test_extras = get_option_from_environment('CIBW_TEST_EXTRAS', platform=platform, default='')
build_verbosity_str = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='')
build_selector = BuildSelector(build_config, skip_config)
build_selector = BuildSelector(build_config=build_config, skip_config=skip_config)
test_selector = TestSelector(skip_config=test_skip)
try:
environment = parse_environment(environment_config)
except (EnvironmentParseError, ValueError):
print(f'cibuildwheel: Malformed environment option "{environment_config}"', file=sys.stderr)
traceback.print_exc(None, sys.stderr)
exit(2)
sys.exit(2)
if dependency_versions == 'pinned':
dependency_constraints: Optional[DependencyConstraints] = DependencyConstraints.with_defaults()
@@ -166,11 +189,20 @@ def main() -> None:
if not any((package_dir / name).exists()
for name in ["setup.py", "setup.cfg", "pyproject.toml"]):
print('cibuildwheel: Could not find setup.py, setup.cfg or pyproject.toml at root of package', file=sys.stderr)
exit(2)
sys.exit(2)
if args.archs is not None:
archs_config_str = args.archs
else:
archs_config_str = get_option_from_environment('CIBW_ARCHS', platform=platform, default='auto')
archs = Architecture.parse_config(archs_config_str, platform=platform)
identifiers = get_build_identifiers(platform, build_selector, archs)
if args.print_build_identifiers:
print_build_identifiers(platform, build_selector)
exit(0)
for identifier in identifiers:
print(identifier)
sys.exit(0)
manylinux_images: Optional[Dict[str, str]] = None
if platform == 'linux':
@@ -202,6 +234,7 @@ def main() -> None:
manylinux_images[build_platform] = image
build_options = BuildOptions(
architectures=archs,
package_dir=package_dir,
output_dir=output_dir,
test_command=test_command,
@@ -212,6 +245,7 @@ def main() -> None:
before_all=before_all,
build_verbosity=build_verbosity,
build_selector=build_selector,
test_selector=test_selector,
repair_command=repair_command,
environment=environment,
dependency_constraints=dependency_constraints,
@@ -223,6 +257,17 @@ def main() -> None:
print_preamble(platform, build_options)
try:
allowed_architectures_check(platform, build_options.architectures)
except ValueError as err:
print("cibuildwheel:", *err.args, file=sys.stderr)
sys.exit(4)
if not identifiers:
print(f'cibuildwheel: No build identifiers selected: {build_selector}', file=sys.stderr)
if not args.allow_empty:
sys.exit(3)
if not output_dir.exists():
output_dir.mkdir(parents=True)
@@ -233,8 +278,7 @@ def main() -> None:
elif platform == 'macos':
cibuildwheel.macos.build(build_options)
else:
print(f'cibuildwheel: Unsupported platform: {platform}', file=sys.stderr)
exit(2)
assert_never(platform)
def detect_obsolete_options() -> None:
@@ -248,7 +292,7 @@ def detect_obsolete_options() -> None:
os.environ[alternative] = os.environ[deprecated]
else:
print(f"Option '{alternative}' is not empty. Please unset '{deprecated}'")
exit(2)
sys.exit(2)
# Check for deprecated identifiers in 'CIBW_BUILD' and 'CIBW_SKIP' options
for option in ['CIBW_BUILD', 'CIBW_SKIP']:
@@ -284,17 +328,22 @@ def print_preamble(platform: str, build_options: BuildOptions) -> None:
print('\nHere we go!\n')
def print_build_identifiers(platform: str, build_selector: BuildSelector) -> None:
python_configurations: List[Any] = []
def get_build_identifiers(
platform: PlatformName, build_selector: BuildSelector, architectures: Set[Architecture]
) -> List[str]:
python_configurations: Union[List[cibuildwheel.linux.PythonConfiguration],
List[cibuildwheel.windows.PythonConfiguration],
List[cibuildwheel.macos.PythonConfiguration]]
if platform == 'linux':
python_configurations = cibuildwheel.linux.get_python_configurations(build_selector)
python_configurations = cibuildwheel.linux.get_python_configurations(build_selector, architectures)
elif platform == 'windows':
python_configurations = cibuildwheel.windows.get_python_configurations(build_selector)
python_configurations = cibuildwheel.windows.get_python_configurations(build_selector, architectures)
elif platform == 'macos':
python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)
else:
assert_never(platform)
for config in python_configurations:
print(config.identifier)
return [config.identifier for config in python_configurations]
def detect_warnings(platform: str, build_options: BuildOptions) -> List[str]:
+86
View File
@@ -0,0 +1,86 @@
import functools
import platform as platform_module
import re
from enum import Enum
from typing import Set
from .typing import PlatformName, assert_never
PRETTY_NAMES = {'linux': 'Linux', 'macos': 'macOS', 'windows': 'Windows'}
@functools.total_ordering
class Architecture(Enum):
value: str
# mac/linux archs
x86_64 = 'x86_64'
i686 = 'i686'
aarch64 = 'aarch64'
ppc64le = 'ppc64le'
s390x = 's390x'
# windows archs
x86 = 'x86'
AMD64 = 'AMD64'
# Allow this to be sorted
def __lt__(self, other: "Architecture") -> bool:
return self.value < other.value
@staticmethod
def parse_config(config: str, platform: PlatformName) -> 'Set[Architecture]':
result = set()
for arch_str in re.split(r'[\s,]+', config):
if arch_str == 'auto':
result |= Architecture.auto_archs(platform=platform)
elif arch_str == 'native':
result.add(Architecture(platform_module.machine()))
elif arch_str == 'all':
result |= Architecture.all_archs(platform=platform)
else:
result.add(Architecture(arch_str))
return result
@staticmethod
def auto_archs(platform: PlatformName) -> 'Set[Architecture]':
native_architecture = Architecture(platform_module.machine())
result = {native_architecture}
if platform == 'linux' and native_architecture == Architecture.x86_64:
# x86_64 machines can run i686 docker containers
result.add(Architecture.i686)
if platform == 'windows' and native_architecture == Architecture.AMD64:
result.add(Architecture.x86)
return result
@staticmethod
def all_archs(platform: PlatformName) -> 'Set[Architecture]':
if platform == 'linux':
return {Architecture.x86_64, Architecture.i686, Architecture.aarch64, Architecture.ppc64le, Architecture.s390x}
elif platform == 'macos':
return {Architecture.x86_64}
elif platform == 'windows':
return {Architecture.x86, Architecture.AMD64}
else:
assert_never(platform)
def allowed_architectures_check(
platform: PlatformName,
architectures: Set[Architecture],
) -> None:
allowed_architectures = Architecture.all_archs(platform)
msg = f'{PRETTY_NAMES[platform]} only supports {sorted(allowed_architectures)} at the moment.'
if platform != 'linux':
msg += ' If you want to set emulation architectures on Linux, use CIBW_ARCHS_LINUX instead.'
if not architectures <= allowed_architectures:
msg = f'Invalid archs option {architectures}. ' + msg
raise ValueError(msg)
if not architectures:
msg = 'Empty archs option set. ' + msg
raise ValueError(msg)
+3 -3
View File
@@ -1,7 +1,7 @@
import subprocess
from typing import Callable, Dict, List, NamedTuple, Optional, Sequence
import bashlex # type: ignore
import bashlex
# a function that takes a command and the environment, and returns the result
EnvironmentExecutor = Callable[[List[str], Dict[str, str]], str]
@@ -50,7 +50,7 @@ def evaluate_node(node: bashlex.ast.node, context: NodeExecutionContext) -> str:
def evaluate_word_node(node: bashlex.ast.node, context: NodeExecutionContext) -> str:
value = node.word
value: str = node.word
for part in node.parts:
part_string = context.input[part.pos[0]:part.pos[1]]
@@ -95,7 +95,7 @@ def evaluate_nodes_as_compound_command(nodes: Sequence[bashlex.ast.node], contex
return result
def evaluate_nodes_as_simple_command(nodes: List[bashlex.ast.node], context: NodeExecutionContext):
def evaluate_nodes_as_simple_command(nodes: List[bashlex.ast.node], context: NodeExecutionContext) -> str:
command = [evaluate_node(part, context=context) for part in nodes]
return context.executor(command, context.environment)
+26 -8
View File
@@ -5,9 +5,11 @@ import shlex
import subprocess
import sys
import uuid
from os import PathLike
from pathlib import Path, PurePath
from typing import IO, Dict, List, Optional, Sequence, Union
from types import TracebackType
from typing import IO, Dict, List, Optional, Sequence, Type, cast
from .typing import PathOrStr, PopenBytes
class DockerContainer:
@@ -23,14 +25,18 @@ class DockerContainer:
'''
UTILITY_PYTHON = '/opt/python/cp38-cp38/bin/python'
process: subprocess.Popen
process: PopenBytes
bash_stdin: IO[bytes]
bash_stdout: IO[bytes]
def __init__(self, docker_image: str, simulate_32_bit: bool = False, cwd: Optional[Union[str, PathLike]] = None):
def __init__(self, docker_image: str, simulate_32_bit: bool = False, cwd: Optional[PathOrStr] = None):
if not docker_image:
raise ValueError("Must have a non-empty docker image to run.")
self.docker_image = docker_image
self.simulate_32_bit = simulate_32_bit
self.cwd = cwd
self.name: Optional[str] = None
def __enter__(self) -> 'DockerContainer':
self.name = f'cibuildwheel-{uuid.uuid4()}'
@@ -68,11 +74,18 @@ class DockerContainer:
return self
def __exit__(self, exc_type, exc_val, exc_tb):
def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None:
self.bash_stdin.close()
self.process.terminate()
self.process.wait()
assert isinstance(self.name, str)
subprocess.run(['docker', 'rm', '--force', '-v', self.name], stdout=subprocess.DEVNULL)
self.name = None
@@ -117,8 +130,12 @@ class DockerContainer:
return [PurePath(p) for p in path_strs]
def call(self, args: Sequence[Union[str, PathLike]], env: Optional[Dict[str, str]] = None,
capture_output=False, cwd: Optional[Union[str, PathLike]] = None) -> str:
def call(
self,
args: Sequence[PathOrStr],
env: Optional[Dict[str, str]] = None,
capture_output: bool = False,
cwd: Optional[PathOrStr] = None) -> str:
chdir = f'cd {cwd}' if cwd else ''
env_assignments = ' '.join(f'{shlex.quote(k)}={shlex.quote(v)}'
@@ -178,11 +195,12 @@ class DockerContainer:
return output
def get_environment(self) -> Dict[str, str]:
return json.loads(self.call([
env = json.loads(self.call([
self.UTILITY_PYTHON,
'-c',
'import sys, json, os; json.dump(os.environ.copy(), sys.stdout)'
], capture_output=True))
return cast(Dict[str, str], env)
def environment_executor(self, command: List[str], environment: Dict[str, str]) -> str:
# used as an EnvironmentExecutor to evaluate commands and capture output
+2 -2
View File
@@ -1,7 +1,7 @@
import bashlex # type: ignore
from typing import Dict, List, Mapping, Optional
import bashlex
from . import bashlex_eval
+24
View File
@@ -0,0 +1,24 @@
"""
These are utilities for the `/bin` scripts, not for the `cibuildwheel` program.
"""
from typing import Any, Dict
import toml.encoder
from packaging.version import Version
class InlineArrayDictEncoder(toml.encoder.TomlEncoder): # type: ignore
def __init__(self) -> None:
super().__init__()
self.dump_funcs[Version] = lambda v: f'"{v}"'
def dump_sections(self, o: Dict[str, Any], sup: str) -> Any:
if all(isinstance(a, list) for a in o.values()):
val = ""
for k, v in o.items():
inner = ",\n ".join(self.dump_inline_table(d_i).strip() for d_i in v)
val += f"{k} = [\n {inner},\n]\n"
return val, self._dict()
else:
return super().dump_sections(o, sup)
+36 -71
View File
@@ -1,36 +1,22 @@
import platform
import subprocess
import sys
import textwrap
from os import PathLike
from pathlib import Path, PurePath
from typing import List, NamedTuple, Union
from typing import List, NamedTuple, Set
from .architecture import Architecture
from .docker_container import DockerContainer
from .logger import log
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
get_build_verbosity_extra_flags, prepare_command)
def matches_platform(identifier: str) -> bool:
pm = platform.machine()
if pm == "x86_64":
# x86_64 machines can run i686 docker containers
if identifier.endswith('x86_64') or identifier.endswith('i686'):
return True
elif pm == "i686":
if identifier.endswith('i686'):
return True
elif pm == "aarch64":
if identifier.endswith('aarch64'):
return True
elif pm == "ppc64le":
if identifier.endswith('ppc64le'):
return True
elif pm == "s390x":
if identifier.endswith('s390x'):
return True
return False
from .typing import PathOrStr
from .util import (
BuildOptions,
BuildSelector,
NonPlatformWheelError,
get_build_verbosity_extra_flags,
prepare_command,
read_python_configs,
resources_dir,
)
class PythonConfiguration(NamedTuple):
@@ -39,47 +25,26 @@ class PythonConfiguration(NamedTuple):
path_str: str
@property
def path(self):
def path(self) -> PurePath:
return PurePath(self.path_str)
def get_python_configurations(build_selector: BuildSelector) -> List[PythonConfiguration]:
python_configurations = [
PythonConfiguration(version='2.7', identifier='cp27-manylinux_x86_64', path_str='/opt/python/cp27-cp27m'),
PythonConfiguration(version='2.7', identifier='cp27-manylinux_x86_64', path_str='/opt/python/cp27-cp27mu'),
PythonConfiguration(version='3.5', identifier='cp35-manylinux_x86_64', path_str='/opt/python/cp35-cp35m'),
PythonConfiguration(version='3.6', identifier='cp36-manylinux_x86_64', path_str='/opt/python/cp36-cp36m'),
PythonConfiguration(version='3.7', identifier='cp37-manylinux_x86_64', path_str='/opt/python/cp37-cp37m'),
PythonConfiguration(version='3.8', identifier='cp38-manylinux_x86_64', path_str='/opt/python/cp38-cp38'),
PythonConfiguration(version='3.9', identifier='cp39-manylinux_x86_64', path_str='/opt/python/cp39-cp39'),
PythonConfiguration(version='2.7', identifier='cp27-manylinux_i686', path_str='/opt/python/cp27-cp27m'),
PythonConfiguration(version='2.7', identifier='cp27-manylinux_i686', path_str='/opt/python/cp27-cp27mu'),
PythonConfiguration(version='3.5', identifier='cp35-manylinux_i686', path_str='/opt/python/cp35-cp35m'),
PythonConfiguration(version='3.6', identifier='cp36-manylinux_i686', path_str='/opt/python/cp36-cp36m'),
PythonConfiguration(version='3.7', identifier='cp37-manylinux_i686', path_str='/opt/python/cp37-cp37m'),
PythonConfiguration(version='3.8', identifier='cp38-manylinux_i686', path_str='/opt/python/cp38-cp38'),
PythonConfiguration(version='3.9', identifier='cp39-manylinux_i686', path_str='/opt/python/cp39-cp39'),
PythonConfiguration(version='2.7', identifier='pp27-manylinux_x86_64', path_str='/opt/python/pp27-pypy_73'),
PythonConfiguration(version='3.6', identifier='pp36-manylinux_x86_64', path_str='/opt/python/pp36-pypy36_pp73'),
PythonConfiguration(version='3.7', identifier='pp37-manylinux_x86_64', path_str='/opt/python/pp37-pypy37_pp73'),
PythonConfiguration(version='3.5', identifier='cp35-manylinux_aarch64', path_str='/opt/python/cp35-cp35m'),
PythonConfiguration(version='3.6', identifier='cp36-manylinux_aarch64', path_str='/opt/python/cp36-cp36m'),
PythonConfiguration(version='3.7', identifier='cp37-manylinux_aarch64', path_str='/opt/python/cp37-cp37m'),
PythonConfiguration(version='3.8', identifier='cp38-manylinux_aarch64', path_str='/opt/python/cp38-cp38'),
PythonConfiguration(version='3.9', identifier='cp39-manylinux_aarch64', path_str='/opt/python/cp39-cp39'),
PythonConfiguration(version='3.5', identifier='cp35-manylinux_ppc64le', path_str='/opt/python/cp35-cp35m'),
PythonConfiguration(version='3.6', identifier='cp36-manylinux_ppc64le', path_str='/opt/python/cp36-cp36m'),
PythonConfiguration(version='3.7', identifier='cp37-manylinux_ppc64le', path_str='/opt/python/cp37-cp37m'),
PythonConfiguration(version='3.8', identifier='cp38-manylinux_ppc64le', path_str='/opt/python/cp38-cp38'),
PythonConfiguration(version='3.9', identifier='cp39-manylinux_ppc64le', path_str='/opt/python/cp39-cp39'),
PythonConfiguration(version='3.5', identifier='cp35-manylinux_s390x', path_str='/opt/python/cp35-cp35m'),
PythonConfiguration(version='3.6', identifier='cp36-manylinux_s390x', path_str='/opt/python/cp36-cp36m'),
PythonConfiguration(version='3.7', identifier='cp37-manylinux_s390x', path_str='/opt/python/cp37-cp37m'),
PythonConfiguration(version='3.8', identifier='cp38-manylinux_s390x', path_str='/opt/python/cp38-cp38'),
PythonConfiguration(version='3.9', identifier='cp39-manylinux_s390x', path_str='/opt/python/cp39-cp39'),
def get_python_configurations(
build_selector: BuildSelector,
architectures: Set[Architecture]
) -> List[PythonConfiguration]:
full_python_configs = read_python_configs('linux')
python_configurations = [PythonConfiguration(**item) for item in full_python_configs]
# return all configurations whose arch is in our `architectures` set,
# and match the build/skip rules
return [
c for c in python_configurations
if any(c.identifier.endswith(arch.value) for arch in architectures)
and build_selector(c.identifier)
]
# skip builds as required
return [c for c in python_configurations if matches_platform(c.identifier) and build_selector(c.identifier)]
def build(options: BuildOptions) -> None:
@@ -90,10 +55,10 @@ def build(options: BuildOptions) -> None:
'If you\'re building on Travis CI, add `services: [docker]` to your .travis.yml.'
'If you\'re building on Circle CI in Linux, add a `setup_remote_docker` step to your .circleci/config.yml',
file=sys.stderr)
exit(2)
sys.exit(2)
assert options.manylinux_images is not None
python_configurations = get_python_configurations(options.build_selector)
python_configurations = get_python_configurations(options.build_selector, options.architectures)
platforms = [
('cp', 'manylinux_x86_64', options.manylinux_images['x86_64']),
('cp', 'manylinux_i686', options.manylinux_images['i686']),
@@ -137,11 +102,11 @@ def build(options: BuildOptions) -> None:
for config in platform_configs:
log.build_start(config.identifier)
dependency_constraint_flags: List[Union[str, PathLike]] = []
dependency_constraint_flags: List[PathOrStr] = []
if config.identifier.startswith("pp"):
# Patch PyPy to make sure headers get installed into a venv
patch_version = '_27' if config.version == '2.7' else ''
patch_path = Path(__file__).absolute().parent / 'resources' / f'pypy_venv{patch_version}.patch'
patch_path = resources_dir / f'pypy_venv{patch_version}.patch'
patch_docker_path = PurePath('/pypy_venv.patch')
docker.copy_into(patch_path, patch_docker_path)
try:
@@ -170,12 +135,12 @@ def build(options: BuildOptions) -> None:
which_python = docker.call(['which', 'python'], env=env, capture_output=True).strip()
if PurePath(which_python) != python_bin / 'python':
print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr)
exit(1)
sys.exit(1)
which_pip = docker.call(['which', 'pip'], env=env, capture_output=True).strip()
if PurePath(which_pip) != python_bin / 'pip':
print("cibuildwheel: pip available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert pip above it.", file=sys.stderr)
exit(1)
sys.exit(1)
if options.before_build:
log.step('Running before_build...')
@@ -215,7 +180,7 @@ def build(options: BuildOptions) -> None:
repaired_wheels = docker.glob(repaired_wheel_dir, '*.whl')
if options.test_command:
if options.test_command and options.test_selector(config.identifier):
log.step('Testing wheel...')
# set up a virtual environment to install and test from, to make sure
@@ -265,7 +230,7 @@ def build(options: BuildOptions) -> None:
except subprocess.CalledProcessError as error:
log.error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
troubleshoot(options.package_dir, error)
exit(1)
sys.exit(1)
def troubleshoot(package_dir: Path, error: Exception) -> None:
+36 -50
View File
@@ -3,7 +3,7 @@ import os
import re
import sys
import time
from typing import Optional, Union
from typing import IO, AnyStr, Optional, Union
from cibuildwheel.util import CIProvider, detect_ci_provider
@@ -35,7 +35,7 @@ class Logger:
step_start_time: Optional[float] = None
active_fold_group_name: Optional[str] = None
def __init__(self):
def __init__(self) -> None:
if sys.platform == 'win32' and hasattr(sys.stdout, 'reconfigure'):
# the encoding on Windows can be a 1-byte charmap, but all CIs
# support utf8, so we hardcode that
@@ -65,7 +65,7 @@ class Logger:
self.fold_mode = 'disabled'
self.colors_enabled = file_supports_color(sys.stdout)
def build_start(self, identifier: str):
def build_start(self, identifier: str) -> None:
self.step_end()
c = self.colors
description = build_description_from_identifier(identifier)
@@ -77,7 +77,7 @@ class Logger:
self.build_start_time = time.time()
self.active_build_identifier = identifier
def build_end(self):
def build_end(self) -> None:
assert self.build_start_time is not None
assert self.active_build_identifier is not None
self.step_end()
@@ -91,12 +91,12 @@ class Logger:
self.build_start_time = None
self.active_build_identifier = None
def step(self, step_description: str):
def step(self, step_description: str) -> None:
self.step_end()
self.step_start_time = time.time()
self._start_fold_group(step_description)
def step_end(self, success=True):
def step_end(self, success: bool = True) -> None:
if self.step_start_time is not None:
self._end_fold_group()
c = self.colors
@@ -109,7 +109,7 @@ class Logger:
self.step_start_time = None
def error(self, error: Union[Exception, str]):
def error(self, error: Union[BaseException, str]) -> None:
self.step_end(success=False)
print()
@@ -119,7 +119,7 @@ class Logger:
c = self.colors
print(f'{c.bright_red}Error{c.end} {error}')
def _start_fold_group(self, name: str):
def _start_fold_group(self, name: str) -> None:
self._end_fold_group()
self.active_fold_group_name = name
fold_start_pattern = FOLD_PATTERNS.get(self.fold_mode, DEFAULT_FOLD_PATTERN)[0]
@@ -129,7 +129,7 @@ class Logger:
print()
sys.stdout.flush()
def _end_fold_group(self):
def _end_fold_group(self) -> None:
if self.active_fold_group_name:
fold_start_pattern = FOLD_PATTERNS.get(self.fold_mode, DEFAULT_FOLD_PATTERN)[1]
identifier = self._fold_group_identifier(self.active_fold_group_name)
@@ -137,7 +137,7 @@ class Logger:
sys.stdout.flush()
self.active_fold_group_name = None
def _fold_group_identifier(self, name: str):
def _fold_group_identifier(self, name: str) -> str:
'''
Travis doesn't like fold groups identifiers that have spaces in. This
method converts them to ascii identifiers
@@ -152,21 +152,21 @@ class Logger:
return identifier.lower()[:20]
@property
def colors(self):
def colors(self) -> "Colors":
if self.colors_enabled:
return Colors.enabled
return Colors(enabled=True)
else:
return Colors.disabled
return Colors(enabled=False)
@property
def symbols(self):
def symbols(self) -> "Symbols":
if self.unicode_enabled:
return Symbols.unicode
return Symbols(unicode=True)
else:
return Symbols.ascii
return Symbols(unicode=False)
def build_description_from_identifier(identifier: str):
def build_description_from_identifier(identifier: str) -> str:
python_identifier, _, platform_identifier = identifier.partition('-')
build_description = ''
@@ -192,45 +192,31 @@ def build_description_from_identifier(identifier: str):
class Colors:
class Enabled:
red = '\033[31m'
green = '\033[32m'
yellow = '\033[33m'
blue = '\033[34m'
cyan = '\033[36m'
bright_red = '\033[91m'
bright_green = '\033[92m'
white = '\033[37m\033[97m'
def __init__(self, *, enabled: bool) -> None:
self.red = '\033[31m' if enabled else ''
self.green = '\033[32m' if enabled else ''
self.yellow = '\033[33m' if enabled else ''
self.blue = '\033[34m' if enabled else ''
self.cyan = '\033[36m' if enabled else ''
self.bright_red = '\033[91m' if enabled else ''
self.bright_green = '\033[92m' if enabled else ''
self.white = '\033[37m\033[97m' if enabled else ''
bg_grey = '\033[48;5;235m'
self.bg_grey = '\033[48;5;235m' if enabled else ''
bold = '\033[1m'
faint = '\033[2m'
self.bold = '\033[1m' if enabled else ''
self.faint = '\033[2m' if enabled else ''
end = '\033[0m'
class Disabled:
def __getattr__(self, attr: str) -> str:
return ''
enabled = Enabled()
disabled = Disabled()
self.end = '\033[0m' if enabled else ''
class Symbols:
class Unicode:
done = ''
error = ''
class Ascii:
done = 'done'
error = 'failed'
unicode = Unicode()
ascii = Ascii()
def __init__(self, *, unicode: bool) -> None:
self.done = '' if unicode else 'done'
self.error = '' if unicode else 'failed'
def file_supports_color(file_obj):
def file_supports_color(file_obj: IO[AnyStr]) -> bool:
"""
Returns True if the running system's terminal supports color.
"""
@@ -242,11 +228,11 @@ def file_supports_color(file_obj):
return (supported_platform and is_a_tty)
def file_is_a_tty(file_obj):
def file_is_a_tty(file_obj: IO[AnyStr]) -> bool:
return hasattr(file_obj, 'isatty') and file_obj.isatty()
def file_supports_unicode(file_obj):
def file_supports_unicode(file_obj: IO[AnyStr]) -> bool:
encoding = getattr(file_obj, 'encoding', None)
if not encoding:
return False
+29 -28
View File
@@ -4,18 +4,27 @@ import shutil
import subprocess
import sys
import tempfile
from os import PathLike
from pathlib import Path
from typing import Dict, List, NamedTuple, Optional, Sequence, Union
from typing import Dict, List, NamedTuple, Optional, Sequence
from .environment import ParsedEnvironment
from .logger import log
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
download, get_build_verbosity_extra_flags, get_pip_script,
install_certifi_script, prepare_command)
from .typing import PathOrStr
from .util import (
BuildOptions,
BuildSelector,
NonPlatformWheelError,
download,
get_build_verbosity_extra_flags,
get_pip_script,
install_certifi_script,
prepare_command,
read_python_configs,
resources_dir,
)
def call(args: Union[str, Sequence[Union[str, PathLike]]], env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None, shell: bool = False) -> int:
def call(args: Sequence[PathOrStr], env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None, shell: bool = False) -> int:
# print the command executing for the logs
if shell:
print(f'+ {args}')
@@ -31,20 +40,12 @@ class PythonConfiguration(NamedTuple):
url: str
def get_python_configurations(build_selector: BuildSelector) -> List[PythonConfiguration]:
python_configurations = [
# CPython
PythonConfiguration(version='2.7', identifier='cp27-macosx_x86_64', url='https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg'),
PythonConfiguration(version='3.5', identifier='cp35-macosx_x86_64', url='https://www.python.org/ftp/python/3.5.4/python-3.5.4-macosx10.6.pkg'),
PythonConfiguration(version='3.6', identifier='cp36-macosx_x86_64', url='https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg'),
PythonConfiguration(version='3.7', identifier='cp37-macosx_x86_64', url='https://www.python.org/ftp/python/3.7.9/python-3.7.9-macosx10.9.pkg'),
PythonConfiguration(version='3.8', identifier='cp38-macosx_x86_64', url='https://www.python.org/ftp/python/3.8.7/python-3.8.7-macosx10.9.pkg'),
PythonConfiguration(version='3.9', identifier='cp39-macosx_x86_64', url='https://www.python.org/ftp/python/3.9.1/python-3.9.1-macosx10.9.pkg'),
# PyPy
PythonConfiguration(version='2.7', identifier='pp27-macosx_x86_64', url='https://downloads.python.org/pypy/pypy2.7-v7.3.3-osx64.tar.bz2'),
PythonConfiguration(version='3.6', identifier='pp36-macosx_x86_64', url='https://downloads.python.org/pypy/pypy3.6-v7.3.3-osx64.tar.bz2'),
PythonConfiguration(version='3.7', identifier='pp37-macosx_x86_64', url='https://downloads.python.org/pypy/pypy3.7-v7.3.3-osx64.tar.bz2'),
]
def get_python_configurations(
build_selector: BuildSelector) -> List[PythonConfiguration]:
full_python_configs = read_python_configs('macos')
python_configurations = [PythonConfiguration(**item) for item in full_python_configs]
# skip builds as required
return [c for c in python_configurations if build_selector(c.identifier)]
@@ -107,8 +108,8 @@ def install_pypy(version: str, url: str) -> Path:
call(['tar', '-C', '/tmp', '-xf', downloaded_tar_bz2])
# Patch PyPy to make sure headers get installed into a venv
patch_version = '_27' if version == '2.7' else ''
patch_path = Path(__file__).absolute().parent / 'resources' / f'pypy_venv{patch_version}.patch'
call(['patch', '--force', '-d', installation_path, patch_path])
patch_path = resources_dir / f'pypy_venv{patch_version}.patch'
call(['patch', '--force', '-p1', '-d', installation_path, '-i', patch_path])
installation_bin_path = installation_path / 'bin'
python_executable = 'pypy3' if version[0] == '3' else 'pypy'
@@ -119,7 +120,7 @@ def install_pypy(version: str, url: str) -> Path:
def setup_python(python_configuration: PythonConfiguration,
dependency_constraint_flags: Sequence[Union[str, PathLike]],
dependency_constraint_flags: Sequence[PathOrStr],
environment: ParsedEnvironment) -> Dict[str, str]:
implementation_id = python_configuration.identifier.split("-")[0]
log.step(f'Installing Python {implementation_id}...')
@@ -155,7 +156,7 @@ def setup_python(python_configuration: PythonConfiguration,
which_python = subprocess.check_output(['which', 'python'], env=env, universal_newlines=True).strip()
if which_python != '/tmp/cibw_bin/python':
print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr)
exit(1)
sys.exit(1)
# install pip & wheel
call(['python', get_pip_script, *dependency_constraint_flags], env=env, cwd="/tmp")
@@ -165,7 +166,7 @@ def setup_python(python_configuration: PythonConfiguration,
which_pip = subprocess.check_output(['which', 'pip'], env=env, universal_newlines=True).strip()
if which_pip != '/tmp/cibw_bin/pip':
print("cibuildwheel: pip available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert pip above it.", file=sys.stderr)
exit(1)
sys.exit(1)
# Set MACOSX_DEPLOYMENT_TARGET to 10.9, if the user didn't set it.
# CPython 3.5 defaults to 10.6, and pypy defaults to 10.7, causing
@@ -202,7 +203,7 @@ def build(options: BuildOptions) -> None:
for config in python_configurations:
log.build_start(config.identifier)
dependency_constraint_flags: Sequence[Union[str, PathLike]] = []
dependency_constraint_flags: Sequence[PathOrStr] = []
if options.dependency_constraints:
dependency_constraint_flags = [
'-c', options.dependency_constraints.get_for_python_version(config.version)
@@ -248,7 +249,7 @@ def build(options: BuildOptions) -> None:
repaired_wheel = next(repaired_wheel_dir.glob('*.whl'))
if options.test_command:
if options.test_command and options.test_selector(config.identifier):
log.step('Testing wheel...')
# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
@@ -297,4 +298,4 @@ def build(options: BuildOptions) -> None:
log.build_end()
except subprocess.CalledProcessError as error:
log.error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
exit(1)
sys.exit(1)
View File
@@ -0,0 +1,67 @@
[linux]
python_configurations = [
{ identifier = "cp27-manylinux_x86_64", version = "2.7", path_str = "/opt/python/cp27-cp27m" },
{ identifier = "cp27-manylinux_x86_64", version = "2.7", path_str = "/opt/python/cp27-cp27mu" },
{ identifier = "cp35-manylinux_x86_64", version = "3.5", path_str = "/opt/python/cp35-cp35m" },
{ identifier = "cp36-manylinux_x86_64", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_x86_64", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_x86_64", version = "3.8", path_str = "/opt/python/cp38-cp38" },
{ identifier = "cp39-manylinux_x86_64", version = "3.9", path_str = "/opt/python/cp39-cp39" },
{ identifier = "cp27-manylinux_i686", version = "2.7", path_str = "/opt/python/cp27-cp27m" },
{ identifier = "cp27-manylinux_i686", version = "2.7", path_str = "/opt/python/cp27-cp27mu" },
{ identifier = "cp35-manylinux_i686", version = "3.5", path_str = "/opt/python/cp35-cp35m" },
{ identifier = "cp36-manylinux_i686", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_i686", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_i686", version = "3.8", path_str = "/opt/python/cp38-cp38" },
{ identifier = "cp39-manylinux_i686", version = "3.9", path_str = "/opt/python/cp39-cp39" },
{ identifier = "pp27-manylinux_x86_64", version = "2.7", path_str = "/opt/python/pp27-pypy_73" },
{ identifier = "pp36-manylinux_x86_64", version = "3.6", path_str = "/opt/python/pp36-pypy36_pp73" },
{ identifier = "pp37-manylinux_x86_64", version = "3.7", path_str = "/opt/python/pp37-pypy37_pp73" },
{ identifier = "cp35-manylinux_aarch64", version = "3.5", path_str = "/opt/python/cp35-cp35m" },
{ identifier = "cp36-manylinux_aarch64", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_aarch64", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_aarch64", version = "3.8", path_str = "/opt/python/cp38-cp38" },
{ identifier = "cp39-manylinux_aarch64", version = "3.9", path_str = "/opt/python/cp39-cp39" },
{ identifier = "cp35-manylinux_ppc64le", version = "3.5", path_str = "/opt/python/cp35-cp35m" },
{ identifier = "cp36-manylinux_ppc64le", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_ppc64le", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_ppc64le", version = "3.8", path_str = "/opt/python/cp38-cp38" },
{ identifier = "cp39-manylinux_ppc64le", version = "3.9", path_str = "/opt/python/cp39-cp39" },
{ identifier = "cp35-manylinux_s390x", version = "3.5", path_str = "/opt/python/cp35-cp35m" },
{ identifier = "cp36-manylinux_s390x", version = "3.6", path_str = "/opt/python/cp36-cp36m" },
{ identifier = "cp37-manylinux_s390x", version = "3.7", path_str = "/opt/python/cp37-cp37m" },
{ identifier = "cp38-manylinux_s390x", version = "3.8", path_str = "/opt/python/cp38-cp38" },
{ identifier = "cp39-manylinux_s390x", version = "3.9", path_str = "/opt/python/cp39-cp39" },
]
[macos]
python_configurations = [
{ identifier = "cp27-macosx_x86_64", version = "2.7", url = "https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg" },
{ identifier = "cp35-macosx_x86_64", version = "3.5", url = "https://www.python.org/ftp/python/3.5.4/python-3.5.4-macosx10.6.pkg" },
{ identifier = "cp36-macosx_x86_64", version = "3.6", url = "https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg" },
{ identifier = "cp37-macosx_x86_64", version = "3.7", url = "https://www.python.org/ftp/python/3.7.9/python-3.7.9-macosx10.9.pkg" },
{ identifier = "cp38-macosx_x86_64", version = "3.8", url = "https://www.python.org/ftp/python/3.8.7/python-3.8.7-macosx10.9.pkg" },
{ identifier = "cp39-macosx_x86_64", version = "3.9", url = "https://www.python.org/ftp/python/3.9.1/python-3.9.1-macosx10.9.pkg" },
{ identifier = "pp27-macosx_x86_64", version = "2.7", url = "https://downloads.python.org/pypy/pypy2.7-v7.3.3-osx64.tar.bz2" },
{ identifier = "pp36-macosx_x86_64", version = "3.6", url = "https://downloads.python.org/pypy/pypy3.6-v7.3.3-osx64.tar.bz2" },
{ identifier = "pp37-macosx_x86_64", version = "3.7", url = "https://downloads.python.org/pypy/pypy3.7-v7.3.3-osx64.tar.bz2" },
]
[windows]
python_configurations = [
{ identifier = "cp27-win32", version = "2.7.18", arch = "32" },
{ identifier = "cp27-win_amd64", version = "2.7.18", arch = "64" },
{ identifier = "cp35-win32", version = "3.5.4", arch = "32" },
{ identifier = "cp35-win_amd64", version = "3.5.4", arch = "64" },
{ identifier = "cp36-win32", version = "3.6.8", arch = "32" },
{ identifier = "cp36-win_amd64", version = "3.6.8", arch = "64" },
{ identifier = "cp37-win32", version = "3.7.9", arch = "32" },
{ identifier = "cp37-win_amd64", version = "3.7.9", arch = "64" },
{ identifier = "cp38-win32", version = "3.8.7", arch = "32" },
{ identifier = "cp38-win_amd64", version = "3.8.7", arch = "64" },
{ identifier = "cp39-win32", version = "3.9.1", arch = "32" },
{ identifier = "cp39-win_amd64", version = "3.9.1", arch = "64" },
{ identifier = "pp27-win32", version = "2.7", arch = "32", url = "https://downloads.python.org/pypy/pypy2.7-v7.3.3-win32.zip" },
{ identifier = "pp36-win32", version = "3.6", arch = "32", url = "https://downloads.python.org/pypy/pypy3.6-v7.3.3-win32.zip" },
{ identifier = "pp37-win32", version = "3.7", arch = "32", url = "https://downloads.python.org/pypy/pypy3.7-v7.3.3-win32.zip" },
]
@@ -37,7 +37,7 @@ six==1.15.0
# virtualenv
typing==3.7.4.3
# via importlib-resources
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -18,7 +18,7 @@ importlib-resources==3.2.1
# via virtualenv
six==1.15.0
# via virtualenv
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -12,15 +12,15 @@ distlib==0.3.1
# via virtualenv
filelock==3.0.12
# via virtualenv
importlib-metadata==3.3.0
importlib-metadata==3.4.0
# via virtualenv
importlib-resources==4.1.1
importlib-resources==5.0.0
# via virtualenv
six==1.15.0
# via virtualenv
typing-extensions==3.7.4.3
# via importlib-metadata
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -34,5 +34,5 @@ zipp==3.4.0
# The following packages are considered to be unsafe in a requirements file:
pip==20.3.3
# via -r cibuildwheel/resources/constraints.in
setuptools==51.1.1
setuptools==51.3.3
# via -r cibuildwheel/resources/constraints.in
@@ -12,13 +12,13 @@ distlib==0.3.1
# via virtualenv
filelock==3.0.12
# via virtualenv
importlib-metadata==3.3.0
importlib-metadata==3.4.0
# via virtualenv
six==1.15.0
# via virtualenv
typing-extensions==3.7.4.3
# via importlib-metadata
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -30,5 +30,5 @@ zipp==3.4.0
# The following packages are considered to be unsafe in a requirements file:
pip==20.3.3
# via -r cibuildwheel/resources/constraints.in
setuptools==51.1.1
setuptools==51.3.3
# via -r cibuildwheel/resources/constraints.in
@@ -14,7 +14,7 @@ filelock==3.0.12
# via virtualenv
six==1.15.0
# via virtualenv
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -24,5 +24,5 @@ wheel==0.36.2
# The following packages are considered to be unsafe in a requirements file:
pip==20.3.3
# via -r cibuildwheel/resources/constraints.in
setuptools==51.1.1
setuptools==51.3.3
# via -r cibuildwheel/resources/constraints.in
@@ -14,7 +14,7 @@ filelock==3.0.12
# via virtualenv
six==1.15.0
# via virtualenv
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -24,5 +24,5 @@ wheel==0.36.2
# The following packages are considered to be unsafe in a requirements file:
pip==20.3.3
# via -r cibuildwheel/resources/constraints.in
setuptools==51.1.1
setuptools==51.3.3
# via -r cibuildwheel/resources/constraints.in
+2 -2
View File
@@ -14,7 +14,7 @@ filelock==3.0.12
# via virtualenv
six==1.15.0
# via virtualenv
virtualenv==20.2.2
virtualenv==20.3.1
# via -r cibuildwheel/resources/constraints.in
wheel==0.36.2
# via
@@ -24,5 +24,5 @@ wheel==0.36.2
# The following packages are considered to be unsafe in a requirements file:
pip==20.3.3
# via -r cibuildwheel/resources/constraints.in
setuptools==51.1.1
setuptools==51.3.3
# via -r cibuildwheel/resources/constraints.in
+1 -1
View File
@@ -23,8 +23,8 @@
import os.path
import pkgutil
import shutil
import sys
import struct
import sys
import tempfile
# Useful for very coarse version differentiation.
@@ -29,6 +29,7 @@ def main():
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
import certifi
# change working directory to the default SSL directory
os.chdir(openssl_dir)
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
@@ -1,22 +1,22 @@
[x86_64]
manylinux1 = quay.io/pypa/manylinux1_x86_64:2020-12-30-e2b3664
manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2020-12-30-3161d69
manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2020-12-30-68d3257
manylinux1 = quay.io/pypa/manylinux1_x86_64:2021-01-11-28ab838
manylinux2010 = quay.io/pypa/manylinux2010_x86_64:2021-01-12-ff3830d
manylinux2014 = quay.io/pypa/manylinux2014_x86_64:2021-01-12-c8250d8
[i686]
manylinux1 = quay.io/pypa/manylinux1_i686:2020-12-30-e2b3664
manylinux2010 = quay.io/pypa/manylinux2010_i686:2020-12-30-3161d69
manylinux2014 = quay.io/pypa/manylinux2014_i686:2020-12-30-68d3257
manylinux1 = quay.io/pypa/manylinux1_i686:2021-01-11-28ab838
manylinux2010 = quay.io/pypa/manylinux2010_i686:2021-01-12-ff3830d
manylinux2014 = quay.io/pypa/manylinux2014_i686:2021-01-12-c8250d8
[pypy_x86_64]
manylinux2010 = pypywheels/manylinux2010-pypy_x86_64:2020-12-11-f1e0e80
[aarch64]
manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2020-12-30-68d3257
manylinux2014 = quay.io/pypa/manylinux2014_aarch64:2021-01-12-c8250d8
[ppc64le]
manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2020-12-30-68d3257
manylinux2014 = quay.io/pypa/manylinux2014_ppc64le:2021-01-12-c8250d8
[s390x]
manylinux2014 = quay.io/pypa/manylinux2014_s390x:2020-12-30-68d3257
manylinux2014 = quay.io/pypa/manylinux2014_s390x:2021-01-12-c8250d8
+28
View File
@@ -0,0 +1,28 @@
import os
import subprocess
import sys
from typing import TYPE_CHECKING, NoReturn, Set, Union
if sys.version_info < (3, 8):
from typing_extensions import Final, Literal, TypedDict
else:
from typing import Final, Literal, TypedDict
__all__ = ("Final", "Literal", "TypedDict", "Set", "Union", "PopenBytes", "PathOrStr", "PlatformName", "PLATFORMS", "assert_never")
if TYPE_CHECKING:
PopenBytes = subprocess.Popen[bytes]
PathOrStr = Union[str, os.PathLike[str]]
else:
PopenBytes = subprocess.Popen
PathOrStr = Union[str, "os.PathLike[str]"]
PlatformName = Literal["linux", "macos", "windows"]
PLATFORMS: Final[Set[PlatformName]] = {"linux", "macos", "windows"}
def assert_never(value: NoReturn) -> NoReturn:
assert False, f'Unhandled value: {value} ({type(value).__name__})' # noqa: B011
+54 -17
View File
@@ -1,19 +1,35 @@
import fnmatch
import itertools
import os
import ssl
import sys
import textwrap
import urllib.request
from enum import Enum
from fnmatch import fnmatch
from pathlib import Path
from time import sleep
from typing import Dict, List, NamedTuple, Optional, Union
from typing import Dict, List, NamedTuple, Optional, Set
import bracex
import certifi
import toml
from .architecture import Architecture
from .environment import ParsedEnvironment
from .typing import PathOrStr, PlatformName
if sys.version_info < (3, 9):
from importlib_resources import files
else:
from importlib.resources import files
def prepare_command(command: str, **kwargs: Union[str, os.PathLike]) -> str:
resources_dir = files('cibuildwheel') / 'resources'
get_pip_script = resources_dir / 'get-pip.py'
install_certifi_script = resources_dir / "install_certifi.py"
def prepare_command(command: str, **kwargs: PathOrStr) -> str:
'''
Preprocesses a command by expanding variables like {python}.
@@ -32,21 +48,45 @@ def get_build_verbosity_extra_flags(level: int) -> List[str]:
return []
class BuildSelector:
def __init__(self, build_config: str, skip_config: str):
def read_python_configs(config: PlatformName) -> List[Dict[str, str]]:
input_file = resources_dir / 'build-platforms.toml'
loaded_file = toml.load(input_file)
results: List[Dict[str, str]] = list(loaded_file[config]['python_configurations'])
return results
class IdentifierSelector:
"""
This class holds a set of build/skip patterns. You call an instance with a
build identifier, and it returns True if that identifier should be
included.
"""
def __init__(self, *, build_config: str, skip_config: str):
self.build_patterns = build_config.split()
self.skip_patterns = skip_config.split()
def __call__(self, build_id: str) -> bool:
def match_any(patterns: List[str]) -> bool:
return any(fnmatch(build_id, pattern) for pattern in patterns)
return match_any(self.build_patterns) and not match_any(self.skip_patterns)
build_patterns = itertools.chain.from_iterable(bracex.expand(p) for p in self.build_patterns)
skip_patterns = itertools.chain.from_iterable(bracex.expand(p) for p in self.skip_patterns)
build: bool = any(fnmatch.fnmatch(build_id, pat) for pat in build_patterns)
skip: bool = any(fnmatch.fnmatch(build_id, pat) for pat in skip_patterns)
return build and not skip
def __repr__(self) -> str:
if not self.skip_patterns:
return f'BuildSelector({" ".join(self.build_patterns)!r})'
return f'{self.__class__.__name__}({" ".join(self.build_patterns)!r})'
else:
return f'BuildSelector({" ".join(self.build_patterns)!r} - {" ".join(self.skip_patterns)!r})'
return f'{self.__class__.__name__}({" ".join(self.build_patterns)!r} - {" ".join(self.skip_patterns)!r})'
class BuildSelector(IdentifierSelector):
pass
class TestSelector(IdentifierSelector):
def __init__(self, *, skip_config: str):
super().__init__(build_config="*", skip_config=skip_config)
# Taken from https://stackoverflow.com/a/107717
@@ -117,7 +157,7 @@ class DependencyConstraints:
else:
return self.base_file_path
def __repr__(self):
def __repr__(self) -> str:
return f'{self.__class__.__name__}{self.base_file_path!r})'
@@ -125,6 +165,7 @@ class BuildOptions(NamedTuple):
package_dir: Path
output_dir: Path
build_selector: BuildSelector
architectures: Set[Architecture]
environment: ParsedEnvironment
before_all: str
before_build: Optional[str]
@@ -132,17 +173,13 @@ class BuildOptions(NamedTuple):
manylinux_images: Optional[Dict[str, str]]
dependency_constraints: Optional[DependencyConstraints]
test_command: Optional[str]
test_selector: TestSelector
before_test: Optional[str]
test_requires: List[str]
test_extras: str
build_verbosity: int
resources_dir = Path(__file__).resolve().parent / 'resources'
get_pip_script = resources_dir / 'get-pip.py'
install_certifi_script = resources_dir / "install_certifi.py"
class NonPlatformWheelError(Exception):
def __init__(self) -> None:
message = textwrap.dedent('''
@@ -164,7 +201,7 @@ def strtobool(val: str) -> bool:
return False
class CIProvider(str, Enum):
class CIProvider(Enum):
travis_ci = 'travis'
appveyor = 'appveyor'
circle_ci = 'circle_ci'
+42 -37
View File
@@ -3,24 +3,32 @@ import shutil
import subprocess
import sys
import tempfile
from os import PathLike
from pathlib import Path
from typing import Dict, List, NamedTuple, Optional, Sequence, Union
from typing import Dict, List, NamedTuple, Optional, Sequence, Set
from zipfile import ZipFile
import toml
from .architecture import Architecture
from .environment import ParsedEnvironment
from .logger import log
from .util import (BuildOptions, BuildSelector, NonPlatformWheelError,
download, get_build_verbosity_extra_flags, get_pip_script,
prepare_command)
from .typing import PathOrStr
from .util import (
BuildOptions,
BuildSelector,
NonPlatformWheelError,
download,
get_build_verbosity_extra_flags,
get_pip_script,
prepare_command,
read_python_configs,
)
IS_RUNNING_ON_AZURE = Path('C:\\hostedtoolcache').exists()
IS_RUNNING_ON_TRAVIS = os.environ.get('TRAVIS_OS_NAME') == 'windows'
def call(args: Sequence[Union[str, PathLike]], env: Optional[Dict[str, str]] = None,
def call(args: Sequence[PathOrStr], env: Optional[Dict[str, str]] = None,
cwd: Optional[str] = None) -> None:
print('+ ' + ' '.join(str(a) for a in args))
# we use shell=True here, even though we don't need a shell due to a bug
@@ -44,37 +52,34 @@ class PythonConfiguration(NamedTuple):
version: str
arch: str
identifier: str
url: Optional[str]
url: Optional[str] = None
def get_python_configurations(build_selector: BuildSelector) -> List[PythonConfiguration]:
python_configurations = [
# CPython
PythonConfiguration(version='2.7.18', arch='32', identifier='cp27-win32', url=None),
PythonConfiguration(version='2.7.18', arch='64', identifier='cp27-win_amd64', url=None),
PythonConfiguration(version='3.5.4', arch='32', identifier='cp35-win32', url=None),
PythonConfiguration(version='3.5.4', arch='64', identifier='cp35-win_amd64', url=None),
PythonConfiguration(version='3.6.8', arch='32', identifier='cp36-win32', url=None),
PythonConfiguration(version='3.6.8', arch='64', identifier='cp36-win_amd64', url=None),
PythonConfiguration(version='3.7.9', arch='32', identifier='cp37-win32', url=None),
PythonConfiguration(version='3.7.9', arch='64', identifier='cp37-win_amd64', url=None),
PythonConfiguration(version='3.8.7', arch='32', identifier='cp38-win32', url=None),
PythonConfiguration(version='3.8.7', arch='64', identifier='cp38-win_amd64', url=None),
PythonConfiguration(version='3.9.1', arch='32', identifier='cp39-win32', url=None),
PythonConfiguration(version='3.9.1', arch='64', identifier='cp39-win_amd64', url=None),
# PyPy
PythonConfiguration(version='2.7', arch='32', identifier='pp27-win32', url='https://downloads.python.org/pypy/pypy2.7-v7.3.3-win32.zip'),
PythonConfiguration(version='3.6', arch='32', identifier='pp36-win32', url='https://downloads.python.org/pypy/pypy3.6-v7.3.3-win32.zip'),
PythonConfiguration(version='3.7', arch='32', identifier='pp37-win32', url='https://downloads.python.org/pypy/pypy3.7-v7.3.3-win32.zip'),
]
def get_python_configurations(
build_selector: BuildSelector,
architectures: Set[Architecture],
) -> List[PythonConfiguration]:
if IS_RUNNING_ON_TRAVIS:
full_python_configs = read_python_configs('windows')
python_configurations = [PythonConfiguration(**item) for item in full_python_configs]
map_arch = {
'32': Architecture.x86,
'64': Architecture.AMD64,
}
custom_compiler = os.environ.get('DISTUTILS_USE_SDK') and os.environ.get('MSSdk')
if IS_RUNNING_ON_TRAVIS and not custom_compiler:
# cannot install VCForPython27.msi which is needed for compiling C software
# try with (and similar): msiexec /i VCForPython27.msi ALLUSERS=1 ACCEPT=YES /passive
python_configurations = [c for c in python_configurations if not c.version.startswith('2.7')]
# skip builds as required
python_configurations = [c for c in python_configurations if build_selector(c.identifier)]
python_configurations = [
c for c in python_configurations
if build_selector(c.identifier) and map_arch[c.arch] in architectures
]
return python_configurations
@@ -108,7 +113,7 @@ def install_pypy(version: str, arch: str, url: str) -> Path:
return installation_path
def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: Sequence[Union[str, PathLike]], environment: ParsedEnvironment) -> Dict[str, str]:
def setup_python(python_configuration: PythonConfiguration, dependency_constraint_flags: Sequence[PathOrStr], environment: ParsedEnvironment) -> Dict[str, str]:
nuget = Path('C:\\cibw\\nuget.exe')
if not nuget.exists():
log.step('Downloading nuget...')
@@ -148,7 +153,7 @@ def setup_python(python_configuration: PythonConfiguration, dependency_constrain
where_python = subprocess.check_output(['where', 'python'], env=env, universal_newlines=True).splitlines()[0].strip()
if where_python != str(installation_path / 'python.exe'):
print("cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.", file=sys.stderr)
exit(1)
sys.exit(1)
# make sure pip is installed
if not (installation_path / 'Scripts' / 'pip.exe').exists():
@@ -157,7 +162,7 @@ def setup_python(python_configuration: PythonConfiguration, dependency_constrain
where_pip = subprocess.check_output(['where', 'pip'], env=env, universal_newlines=True).splitlines()[0].strip()
if where_pip.strip() != str(installation_path / 'Scripts' / 'pip.exe'):
print("cibuildwheel: pip available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert pip above it.", file=sys.stderr)
exit(1)
sys.exit(1)
log.step('Installing build tools...')
@@ -194,7 +199,7 @@ def pep_518_cp35_workaround(package_dir: Path, env: Dict[str, str]) -> None:
log.step('Performing PEP518 workaround...')
with tempfile.TemporaryDirectory() as d:
reqfile = Path(d) / "requirements.txt"
with reqfile.open("w") as f:
with reqfile.open('w') as f:
for r in requirements:
print(r, file=f)
call(['pip', 'install', '-r', reqfile], env=env)
@@ -212,12 +217,12 @@ def build(options: BuildOptions) -> None:
before_all_prepared = prepare_command(options.before_all, project='.', package=options.package_dir)
shell(before_all_prepared, env=env)
python_configurations = get_python_configurations(options.build_selector)
python_configurations = get_python_configurations(options.build_selector, options.architectures)
for config in python_configurations:
log.build_start(config.identifier)
dependency_constraint_flags: Sequence[Union[str, PathLike]] = []
dependency_constraint_flags: Sequence[PathOrStr] = []
if options.dependency_constraints:
dependency_constraint_flags = [
'-c', options.dependency_constraints.get_for_python_version(config.version)
@@ -270,7 +275,7 @@ def build(options: BuildOptions) -> None:
repaired_wheel = next(repaired_wheel_dir.glob('*.whl'))
if options.test_command:
if options.test_command and options.test_selector(config.identifier):
log.step('Testing wheel...')
# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
@@ -323,4 +328,4 @@ def build(options: BuildOptions) -> None:
log.build_end()
except subprocess.CalledProcessError as error:
log.error(f'Command {error.cmd} failed with code {error.returncode}. {error.stdout}')
exit(1)
sys.exit(1)
+15
View File
@@ -32,8 +32,21 @@ So, if we can, I'd like to improve the experience on errors as well. In [this](h
Maintainer notes
----------------
## Local testing
You should run:
```python
python3 -m venv venv
. venv/bin/activate
pip install -e .[dev]
```
To prepare a development environment.
## Testing minimal configs
cibuildwheel's _minimal_ example configs can be tested on a simple project on cibuildwheel's existing CI. These should be run whenever the minimal configs change.
To test minimal configs, make sure you have a clean git repo, then run the script:
@@ -48,6 +61,8 @@ The script then outputs a Markdown table that can be copy/pasted into a PR to mo
## Preparing environments
This has been moved to using docker, so you only need the following instructions if you add `--no-docker` to avoid using docker.
The dependency update script in the next section requires multiple python versions installed. One way to do this is to use `pyenv`:
```bash
+58
View File
@@ -229,3 +229,61 @@
ci: [travisci]
os: [windows, apple, linux]
notes: Dependency injection framework for Python, uses Windows TravisCI
- name: numexpr
gh: pydata/numexpr
ci: [github, travisci]
os: [windows, apple, linux]
- name: PyTables
gh: PyTables/PyTables
ci: [github]
os: [windows, apple, linux]
- name: dd-trace-py
gh: DataDog/dd-trace-py
ci: [github]
os: [windows, apple, linux]
notes: Uses custom alternate arch emulation on GitHub
- name: Tokenizer
gh: OpenNMT/Tokenizer
ci: [github, travisci]
os: [apple, linux]
- name: matrixprofile
gh: matrix-profile-foundation/matrixprofile
ci: [travisci]
os: [windows, apple, linux]
- name: cyvcf2
gh: brentp/cyvcf2
ci: [github]
os: [apple, linux]
- name: CTranslate2
gh: OpenNMT/CTranslate2
ci: [github]
os: [apple, linux]
notes: Includes libraries from the [Intel oneAPI toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit.html). The Linux wheels also include CUDA libraries for GPU execution.
- name: MyPy
gh: mypyc/mypy_mypyc-wheels
stars: python/mypy
ci: [github]
os: [apple, linux, windows]
notes: MyPyC, the compiled component of MyPy.
- name: Imagecodecs (fork)
gh: czaki/imagecodecs_build
stars: cgohlke/imagecodecs
ci: [azurepipelines]
ci_config: azure-pipelines.yaml
os: [apple, linux]
notes: Over 20 external dependencies in compiled libraries, custom docker image, `libomp`, `openblas` and `install_name_tool` for macOS.
- name: ruptures
gh: deepcharles/ruptures
ci: [github]
os: [apple, linux, windows]
notes: Extensive Cython + NumPy [pyproject.toml](https://github.com/deepcharles/ruptures/blob/master/pyproject.toml) example.
+23 -3
View File
@@ -24,6 +24,26 @@ Linux wheels are built in the [`manylinux` docker images](https://github.com/pyp
- Alternative dockers images can be specified with the `CIBW_MANYLINUX_X86_64_IMAGE`, `CIBW_MANYLINUX_I686_IMAGE`, and `CIBW_MANYLINUX_PYPY_X86_64_IMAGE` options to allow for a custom, preconfigured build environment for the Linux builds. See [options](options.md#manylinux-image) for more details.
### Building non-native architectures using emulation {: #emulation}
cibuildwheel supports building non-native architectures on Linux, via
emulation through the binfmt_misc kernel feature. The easiest way to use this
is via the [docker/setup-qemu-action][setup-qemu-action] on Github Actions or
[tonistiigi/binfmt][binfmt].
[setup-qemu-action]: https://github.com/docker/setup-qemu-action
[binfmt]: https://hub.docker.com/r/tonistiigi/binfmt
Check out the following config for an example of how to set it up on Github
Actions. Once QEMU is set up and registered, you just need to set the
`CIBW_ARCHS_LINUX` environment variable (or use the `--archs` option on
Linux), and the other architectures are emulated automatically.
> .github/workflows/build.yml
```yaml
{% include "../examples/github-with-qemu.yml" %}
```
### Building packages with optional C extensions
`cibuildwheel` defines the environment variable `CIBUILDWHEEL` to the value `1` allowing projects for which the C extension is optional to make it mandatory when building wheels.
@@ -93,10 +113,10 @@ There are two suggested methods for keeping cibuildwheel up to date that instead
If you use GitHub Actions for builds, you can use cibuildwheel as an action:
```yaml
uses: joerick/cibuildwheel@v1.7.3
uses: joerick/cibuildwheel@v1.8.0
```
This is a composite step that just installs and runs cibuildwheel. You can set command-line options as `with:` parameters, and use `env:` as normal.
This is a composite step that just runs cibuildwheel using pipx. You can set command-line options as `with:` parameters, and use `env:` as normal.
Then, your `dependabot.yml` file could look like this:
@@ -119,7 +139,7 @@ The second option, and the only one that supports other CI systems, is using a `
```bash
# requirements-cibw.txt
cibuildwheel==1.7.3
cibuildwheel==1.8.0
```
Then your install step would have `python -m pip install -r requirements-cibw.txt` in it. Your `dependabot.yml` file could look like this:
+86 -13
View File
@@ -75,7 +75,7 @@ Space-separated list of builds to build and skip. Each build has an identifier l
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 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:
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:
<div class="build-id-table-marker"></div>
@@ -89,7 +89,7 @@ When setting the options, you can use shell-style globbing syntax (as per [`fnma
| 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 |
| 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 | | | |
| PyPy 3.7 (beta) v7.3.3 | pp37-macosx_x86_64 | pp37-manylinux_x86_64 | | | pp37-win32 | | | |
The list of supported and currently selected build identifiers can also be retrieved by passing the `--print-build-identifiers` flag to `cibuildwheel`.
@@ -124,12 +124,12 @@ CIBW_SKIP: cp27-* cp35-*
# Skip Python 3.6 on Linux
CIBW_SKIP: cp36-manylinux*
# Only build on Python 3 and skip 32-bit builds
CIBW_BUILD: cp3?-*
# Only build on Python 3 (ready for 3.10 when it comes) and skip 32-bit builds
CIBW_BUILD: {cp,pp}3*-*
CIBW_SKIP: "*-win32 *-manylinux_i686"
# Only build PyPy and CPython 3
CIBW_BUILD: pp* cp3?-*
CIBW_BUILD: pp* cp3*-*
# Disable building PyPy wheels on all platforms
CIBW_SKIP: pp*
@@ -155,6 +155,34 @@ CIBW_SKIP: pp*
}
</style>
### `CIBW_ARCHS_LINUX` {: #archs}
> Build non-native architectures
A space-separated list of architectures to build. Use this in conjunction with
emulation, such as that provided by [docker/setup-qemu-action][setup-qemu-action]
or [tonistiigi/binfmt][binfmt], to build architectures other than those your
machine natively supports.
Options: `auto` `native` `all` `x86_64` `i686` `aarch64` `ppc64le` `s390x`
Default: `auto`, meaning the native archs supported on the build machine. For
example, on an `x86_64` machine, `auto` expands to `x86_64` and `i686`.
`native` will only build on the exact architecture you currently are on; it will
not add `i686` for `x86_64`.
`all` will expand to all known architectures; remember to use build selectors
to limit builds for each job; this list could grow in the future.
[setup-qemu-action]: https://github.com/docker/setup-qemu-action
[binfmt]: https://hub.docker.com/r/tonistiigi/binfmt
#### Examples
```yaml
# On an intel runner with qemu installed, build Intel and ARM wheels
CIBW_ARCHS_LINUX: "auto aarch64"
```
## Build customization
@@ -221,7 +249,7 @@ CIBW_BEFORE_ALL_LINUX: yum install -y libffi-dev
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.
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. This is reproducible, and users who do not get your wheels (such as Alpine or ClearLinux users) will still benefit.
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`.
@@ -232,22 +260,45 @@ Platform-specific variants also available:<br/>
#### Examples
```yaml
# install your project and dependencies before building
CIBW_BEFORE_BUILD: pip install .
# install something required for the build
# 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: yum install -y libffi-dev && pip install .
CIBW_BEFORE_BUILD_LINUX: yum install -y libffi-dev && 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}/bin/prepare_for_build.sh"
CIBW_BEFORE_BUILD: "{package}/script/prepare_for_build.sh"
```
!!! note
If you need dependencies installed for the build, we recommend using pyproject.toml. This is an example pyproject.toml file:
[build-system]
requires = [
"setuptools>=42",
"wheel",
"Cython",
"numpy==1.11.3; python_version<='3.6'",
"numpy==1.14.5; python_version=='3.7'",
"numpy==1.17.3; python_version=='3.8'",
"numpy==1.19.4; python_version>='3.9'",
]
build-backend = "setuptools.build_meta"
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).
[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_REPAIR_WHEEL_COMMAND` {: #repair-wheel-command}
> Execute a shell command to repair each (non-pure Python) built wheel
@@ -465,6 +516,18 @@ Platform-specific variants also available:<br/>
CIBW_TEST_EXTRAS: test,qt
```
### `CIBW_TEST_SKIP` {: #test-skip}
> Skip running tests on some builds
This will skip testing on any identifiers that match the given skip patterns (see [`CIBW_SKIP`](#build-skip)). This can be used to mask out tests for wheels that have missing dependencies upstream that are slow or hard to build, or to mask up slow tests on emulated architectures.
#### Examples
```yaml
# Will avoid testing on emulated architectures
CIBW_TEST_SKIP: "*-manylinux_{aarch64,ppc64le,s390x}"
```
## Other
@@ -488,7 +551,8 @@ CIBW_BUILD_VERBOSITY: 1
```text
usage: cibuildwheel [-h] [--platform {auto,linux,macos,windows}]
[--output-dir OUTPUT_DIR] [--print-build-identifiers]
[--archs ARCHS] [--output-dir OUTPUT_DIR]
[--print-build-identifiers] [--allow-empty]
[package_dir]
Build wheels for all the platforms.
@@ -510,11 +574,20 @@ optional arguments:
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. Default: auto.
--archs ARCHS Comma-separated list of CPU architectures to build
for. When set to 'auto', builds the architectures
natively supported on this machine. Set this option to
build an architecture via emulation, for example,
using binfmt_misc and QEMU. Default: auto. Choices:
auto, native, all, x86_64, i686, aarch64, ppc64le,
s390x, x86, AMD64
--output-dir OUTPUT_DIR
Destination folder for the wheels.
--print-build-identifiers
Print the build identifiers matched by the current
invocation and exit.
--allow-empty Do not report an error code if the build does not
match any wheels.
```
<style>
+2 -2
View File
@@ -17,7 +17,7 @@ For more info on this file, check out the [docs](https://help.github.com/en/acti
[`examples/github-deploy.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI.
You can also use cibuildwheel directly as an action with `uses: joerick/cibuildwheel@v1.7.3`; this combines the download and run steps into a single action, and command line arguments are available via `with:`. This makes it easy to manage cibuildwheel updates via normal actions update mechanisms like dependabot, see [Automatic updates](faq.md#automatic-updates).
You can also use cibuildwheel directly as an action with `uses: joerick/cibuildwheel@v1.8.0`; this combines the download and run steps into a single action, and command line arguments are available via `with:`. This makes it easy to manage cibuildwheel updates via normal actions update mechanisms like dependabot, see [Automatic updates](faq.md#automatic-updates).
# Azure Pipelines [linux/mac/windows] {: #azure-pipelines}
@@ -44,7 +44,7 @@ To build Linux, Mac, and Windows wheels on Travis CI, create a `.travis.yml` fil
{% include "../examples/travis-ci-minimal.yml" %}
```
Note that building Windows Python 2.7 wheels on Travis is unsupported.
Note that building Windows Python 2.7 wheels on Travis is unsupported unless using a newer compiler [via a workaround](cpp_standards.md).
Commit this file, enable building of your repo on Travis CI, and push.
+1 -1
View File
@@ -12,7 +12,7 @@ stack: python 3.7
init:
- cmd: set PATH=C:\Python37;C:\Python37\Scripts;%PATH%
install: python -m pip install cibuildwheel==1.7.3
install: python -m pip install cibuildwheel==1.8.0
build_script: python -m cibuildwheel --output-dir wheelhouse
+3 -3
View File
@@ -6,7 +6,7 @@ jobs:
- bash: |
set -o errexit
python3 -m pip install --upgrade pip
pip3 install cibuildwheel==1.7.3
pip3 install cibuildwheel==1.8.0
displayName: Install dependencies
- bash: cibuildwheel --output-dir wheelhouse .
displayName: Build wheels
@@ -20,7 +20,7 @@ jobs:
- bash: |
set -o errexit
python3 -m pip install --upgrade pip
python3 -m pip install cibuildwheel==1.7.3
python3 -m pip install cibuildwheel==1.8.0
displayName: Install dependencies
- bash: cibuildwheel --output-dir wheelhouse .
displayName: Build wheels
@@ -36,7 +36,7 @@ jobs:
- bash: |
set -o errexit
python -m pip install --upgrade pip
pip install cibuildwheel==1.7.3
pip install cibuildwheel==1.8.0
displayName: Install dependencies
- bash: cibuildwheel --output-dir wheelhouse .
displayName: Build wheels
+2 -2
View File
@@ -11,7 +11,7 @@ jobs:
- run:
name: Build the Linux wheels.
command: |
pip3 install --user cibuildwheel==1.7.3
pip3 install --user cibuildwheel==1.8.0
cibuildwheel --output-dir wheelhouse
- store_artifacts:
path: wheelhouse/
@@ -25,7 +25,7 @@ jobs:
- run:
name: Build the OS X wheels.
command: |
pip3 install cibuildwheel==1.7.3
pip3 install cibuildwheel==1.8.0
cibuildwheel --output-dir wheelhouse
- store_artifacts:
path: wheelhouse/
+2 -2
View File
@@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
os: [ubuntu-18.04, windows-2019, macos-10.15]
steps:
- uses: actions/checkout@v2
@@ -28,7 +28,7 @@ jobs:
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==1.7.3
python -m pip install cibuildwheel==1.8.0
- name: Install Visual C++ for Python 2.7
if: runner.os == 'Windows'
+2 -2
View File
@@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
os: [ubuntu-18.04, windows-2019, macos-10.15]
steps:
- uses: actions/checkout@v2
@@ -20,7 +20,7 @@ jobs:
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==1.7.3
python -m pip install cibuildwheel==1.8.0
- name: Install Visual C++ for Python 2.7
if: runner.os == 'Windows'
+46
View File
@@ -0,0 +1,46 @@
name: Build
on: [push, pull_request]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, windows-2019, macos-10.15]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==1.8.0
- name: Install Visual C++ for Python 2.7
if: runner.os == 'Windows'
run: |
choco install vcpython27 -f -y
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build wheels
run: |
python -m cibuildwheel --output-dir wheelhouse
env:
# configure cibuildwheel to build native archs ('auto'), and some
# emulated ones
CIBW_ARCHS_LINUX: auto aarch64 ppc64le s390x
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
- ln -s /c/Python38/python.exe /c/Python38/python3.exe
install:
- python3 -m pip install cibuildwheel==1.7.3
- python3 -m pip install cibuildwheel==1.8.0
script:
# build the wheels, put them into './wheelhouse'
+1 -1
View File
@@ -26,7 +26,7 @@ jobs:
- ln -s /c/Python38/python.exe /c/Python38/python3.exe
install:
- python3 -m pip install cibuildwheel==1.7.3
- python3 -m pip install cibuildwheel==1.8.0
script:
# build the wheels, put them into './wheelhouse'
+3 -3
View File
@@ -55,7 +55,7 @@ jobs:
- stage: deploy
name: Build and deploy Linux wheels
services: docker
install: python3 -m pip install cibuildwheel==1.7.3
install: python3 -m pip install cibuildwheel==1.8.0
script: python3 -m cibuildwheel --output-dir wheelhouse
after_success: |
python3 -m pip install twine
@@ -65,7 +65,7 @@ jobs:
name: Build and deploy macOS wheels
os: osx
language: shell
install: python3 -m pip install cibuildwheel==1.7.3
install: python3 -m pip install cibuildwheel==1.8.0
script: python3 -m cibuildwheel --output-dir wheelhouse
after_success: |
python3 -m pip install twine
@@ -75,7 +75,7 @@ jobs:
name: Build and deploy Windows wheels
os: windows
language: shell
install: python3 -m pip install cibuildwheel==1.7.3
install: python3 -m pip install cibuildwheel==1.8.0
script: python3 -m cibuildwheel --output-dir wheelhouse
after_success: |
python3 -m pip install twine
+1 -13
View File
@@ -1,13 +1 @@
-e .
pytest
pytest-timeout
mkdocs==1.0.4
mkdocs-include-markdown-plugin==2.1.1
pymdown-extensions
pip-tools
requests
click
mypy
pyyaml
pygithub
typing-extensions
-e .[dev]
+91 -4
View File
@@ -1,3 +1,69 @@
[metadata]
name = cibuildwheel
version = 1.8.0
description = Build Python wheels on CI with minimal configuration.
long_description = file: README.md
long_description_content_type = text/markdown
author = Joe Rickerby
author_email = joerick@mac.com
url = https://github.com/joerick/cibuildwheel
license = BSD
classifiers =
Intended Audience :: Developers
Natural Language :: English
Programming Language :: Python :: 3
Development Status :: 5 - Production/Stable
License :: OSI Approved :: BSD License
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Build Tools
project_urls =
Changelog=https://github.com/joerick/cibuildwheel#changelog
Documentation=https://cibuildwheel.readthedocs.io/
keywords = ci,wheel,packaging,pypi,travis,appveyor,macos,linux,windows
[options]
packages = find:
zip_safe = False
include_package_data = True
python_requires = >=3.6
install_requires =
bashlex!=0.13
toml
certifi
bracex
typing_extensions; python_version < '3.8'
importlib_resources>=1.4; python_version < '3.9'
[options.package_data]
cibuildwheel = resources/*
[options.extras_require]
dev =
click
mkdocs-include-markdown-plugin==2.1.1
mkdocs==1.0.4
mypy
pip-tools
pygithub
pymdown-extensions
pytest
pytest-timeout
pyyaml
requests
typing-extensions
packaging>=20.8
rich>=9.6
[options.packages.find]
include =
cibuildwheel
[options.entry_points]
console_scripts =
cibuildwheel = cibuildwheel.__main__:main
[flake8]
ignore = E501,W503,E741,E226,B950
select = C,E,F,W,B,B9
@@ -18,12 +84,14 @@ junit_family=xunit2
[mypy]
python_version = 3.6
files = cibuildwheel,test
files = cibuildwheel,test,unit_test,bin
warn_unused_configs = True
warn_redundant_casts = True
[mypy-cibuildwheel]
[mypy-test.*]
check_untyped_defs = True
[mypy-cibuildwheel.*,unit_test.*]
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
@@ -37,5 +105,24 @@ warn_return_any = True
no_implicit_reexport = True
strict_equality = True
[mypy-pytest,setuptools]
[mypy-setuptools.*]
ignore_missing_imports = True
# Ignored for pre-commit to speed up check
# Not ignored if manually running and pytest installed
[mypy-pytest.*]
ignore_missing_imports = True
[mypy-bashlex.*]
ignore_missing_imports = True
# Has type stubs, but no pyproject.toml or .pyi files in the wheel.
[mypy-toml.*]
ignore_missing_imports = True
[mypy-bracex.*]
ignore_missing_imports = True
[tool:isort]
profile=black
multi_line_output=3
+2 -48
View File
@@ -1,49 +1,3 @@
# -*- coding: utf-8 -*-
from pathlib import Path
from setuptools import setup
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
this_directory = Path(__file__).parent
long_description = (this_directory / 'README.md').read_text(encoding='utf-8')
setup(
name='cibuildwheel',
version='1.7.3',
install_requires=['bashlex!=0.13', 'toml', 'certifi'],
description="Build Python wheels on CI with minimal configuration.",
long_description=long_description,
long_description_content_type='text/markdown',
author="Joe Rickerby",
author_email='joerick@mac.com',
url='https://github.com/joerick/cibuildwheel',
project_urls={
'Changelog': 'https://github.com/joerick/cibuildwheel#changelog',
'Documentation': 'https://cibuildwheel.readthedocs.io/',
},
packages=['cibuildwheel', ],
license="BSD",
zip_safe=False,
package_data={
'cibuildwheel': ['resources/*'],
},
# Supported python versions
python_requires='>=3.6',
keywords='ci wheel packaging pypi travis appveyor macos linux windows',
classifiers=[
'Intended Audience :: Developers',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development :: Build Tools',
],
entry_points={
'console_scripts': [
'cibuildwheel = cibuildwheel.__main__:main',
],
},
)
setup()
+21
View File
@@ -0,0 +1,21 @@
import pytest
def pytest_addoption(parser):
parser.addoption(
"--run-emulation", action="store_true", default=False, help="run emulation tests"
)
def pytest_configure(config):
config.addinivalue_line("markers", "emulation: mark test requiring qemu binfmt_misc to run")
def pytest_collection_modifyitems(config, items):
if config.getoption("--run-emulation"):
# --run-emulation given in cli: do not skip emulation tests
return
skip_emulation = pytest.mark.skip(reason="need --run-emulation option to run")
for item in items:
if "emulation" in item.keywords:
item.add_marker(skip_emulation)
+2
View File
@@ -1,8 +1,10 @@
import platform
import textwrap
import pytest
from cibuildwheel.logger import Logger
from . import test_projects, utils
basic_project = test_projects.new_c_project(
+3 -3
View File
@@ -1,9 +1,9 @@
import pytest
import subprocess
import textwrap
from . import utils
from . import test_projects
import pytest
from . import test_projects, utils
project_with_before_build_asserts = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
+3 -3
View File
@@ -1,9 +1,9 @@
import pytest
import subprocess
import textwrap
from . import utils
from . import test_projects
import pytest
from . import test_projects, utils
project_with_before_build_asserts = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
+1 -2
View File
@@ -1,5 +1,4 @@
from . import test_projects
from . import utils
from . import test_projects, utils
before_test_project = test_projects.new_c_project()
before_test_project.files['test/spam_test.py'] = r'''
+1 -2
View File
@@ -1,7 +1,6 @@
import textwrap
from . import utils
from . import test_projects
from . import test_projects, utils
project_with_skip_asserts = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
+1 -1
View File
@@ -202,7 +202,7 @@ def test_cpp17_py27_modern_msvc_workaround(tmp_path):
add_env_x64['CIBW_BUILD'] = 'cp27-win_amd64'
actual_wheels += utils.cibuildwheel_run(project_dir, add_env=add_env_x64)
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0')
expected_wheels = [w for w in utils.expected_wheels('spam', '0.1.0', exclude_27=False)
if 'cp27-cp27m-win' in w
or 'pp27-pypy_73-win32' in w]
+10 -4
View File
@@ -1,11 +1,11 @@
import re
import pytest
import textwrap
import pytest
import cibuildwheel.util
from . import utils
from . import test_projects
from . import test_projects, utils
project_with_expected_version_checks = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
@@ -52,6 +52,9 @@ def test_pinned_versions(tmp_path, python_version):
if utils.platform == 'linux':
pytest.skip('linux doesn\'t pin individual tool versions, it pins manylinux images instead')
if utils.IS_WINDOWS_RUNNING_ON_TRAVIS and python_version == '2.7':
pytest.skip('Windows + Travis CI requires a workaround')
project_dir = tmp_path / 'project'
project_with_expected_version_checks.generate(project_dir)
@@ -114,6 +117,9 @@ def test_dependency_constraints_file(tmp_path, python_version):
if utils.platform == 'linux':
pytest.skip('linux doesn\'t pin individual tool versions, it pins manylinux images instead')
if utils.IS_WINDOWS_RUNNING_ON_TRAVIS and python_version == '2.7':
pytest.skip('Windows + Travis CI requires a workaround')
project_dir = tmp_path / 'project'
project_with_expected_version_checks.generate(project_dir)
+1 -2
View File
@@ -3,8 +3,7 @@ import textwrap
import pytest
from . import utils
from . import test_projects
from . import test_projects, utils
dockcross_only_project = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
+53
View File
@@ -0,0 +1,53 @@
import subprocess
import pytest
from . import test_projects, utils
project_with_a_test = test_projects.new_c_project()
project_with_a_test.files['test/spam_test.py'] = r'''
import spam
def test_spam():
assert spam.system('python -c "exit(0)"') == 0
assert spam.system('python -c "exit(1)"') != 0
'''
@pytest.mark.emulation
def test(tmp_path):
project_dir = tmp_path / 'project'
project_with_a_test.generate(project_dir)
# build and test the wheels
actual_wheels = utils.cibuildwheel_run(project_dir, add_env={
'CIBW_TEST_REQUIRES': 'pytest',
'CIBW_TEST_COMMAND': 'pytest {project}/test',
'CIBW_ARCHS': 'aarch64 ppc64le s390x',
})
# also check that we got the right wheels
expected_wheels = (
utils.expected_wheels('spam', '0.1.0', machine_arch='aarch64')
+ utils.expected_wheels('spam', '0.1.0', machine_arch='ppc64le')
+ utils.expected_wheels('spam', '0.1.0', machine_arch='s390x')
)
assert set(actual_wheels) == set(expected_wheels)
def test_setting_arch_on_other_platforms(tmp_path, capfd):
if utils.platform == 'linux':
pytest.skip('this test checks the behaviour on platforms other than linux')
project_dir = tmp_path / 'project'
project_with_a_test.generate(project_dir)
# build and test the wheels
with pytest.raises(subprocess.CalledProcessError):
utils.cibuildwheel_run(project_dir, add_env={
'CIBW_ARCHS': 'aarch64',
})
captured = capfd.readouterr()
assert "Invalid archs option" in captured.err
+3 -3
View File
@@ -1,10 +1,10 @@
import os
import pytest
import subprocess
import textwrap
from . import utils
from . import test_projects
import pytest
from . import test_projects, utils
project_with_environment_asserts = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
+1 -2
View File
@@ -3,8 +3,7 @@ import textwrap
import pytest
from . import utils
from . import test_projects
from . import test_projects, utils
# TODO: specify these at runtime according to manylinux_image
project_with_manylinux_symbols = test_projects.new_c_project(
+3 -3
View File
@@ -1,7 +1,7 @@
import textwrap
from . import test_projects
from . import utils
import os
import textwrap
from . import test_projects, utils
basic_project = test_projects.new_c_project(
setup_py_add=textwrap.dedent(
+1 -3
View File
@@ -1,10 +1,8 @@
from pathlib import Path
from typing import Any, Dict, Union
import jinja2
from typing import Union, Dict, Any
FilesDict = Dict[str, Union[str, jinja2.Template]]
TemplateContext = Dict[str, Any]
+1 -1
View File
@@ -1,6 +1,6 @@
import jinja2
from .base import TestProject
from .base import TestProject
SPAM_C_TEMPLATE = r'''
#include <Python.h>
+3 -1
View File
@@ -1,6 +1,8 @@
import subprocess
import pytest
from test import test_projects
import pytest
from . import utils
pure_python_project = test_projects.TestProject()
+1 -2
View File
@@ -1,7 +1,6 @@
import textwrap
from . import utils
from . import test_projects
from . import test_projects, utils
project_with_ssl_tests = test_projects.new_c_project(
setup_py_add=textwrap.dedent(r'''
+1 -2
View File
@@ -4,8 +4,7 @@ import textwrap
import pytest
from . import utils
from . import test_projects
from . import test_projects, utils
project_with_a_test = test_projects.new_c_project(
setup_cfg_add=textwrap.dedent(r'''
+3 -1
View File
@@ -1,7 +1,9 @@
import subprocess
import pytest
from .test_projects import TestProject
from . import utils
from .test_projects import TestProject
so_file_project = TestProject()
+1 -2
View File
@@ -2,8 +2,7 @@ import textwrap
import pytest
from . import utils
from . import test_projects
from . import test_projects, utils
project_with_unicode = test_projects.new_c_project(
spam_c_function_add=textwrap.dedent(r'''
+12 -7
View File
@@ -76,7 +76,8 @@ def cibuildwheel_run(project_path, package_dir='.', env=None, add_env=None, outp
def expected_wheels(package_name, package_version, manylinux_versions=None,
macosx_deployment_target='10.9'):
macosx_deployment_target='10.9', machine_arch=None, *,
exclude_27=IS_WINDOWS_RUNNING_ON_TRAVIS):
'''
Returns a list of expected wheels from a run of cibuildwheel.
'''
@@ -85,15 +86,18 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
# {python tag} and {abi tag} are closely related to the python interpreter used to build the wheel
# so we'll merge them below as python_abi_tag
if machine_arch is None:
machine_arch = pm.machine()
if manylinux_versions is None:
if pm.machine() == 'x86_64':
if machine_arch == 'x86_64':
manylinux_versions = ['manylinux1', 'manylinux2010']
else:
manylinux_versions = ['manylinux2014']
python_abi_tags = ['cp35-cp35m', 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38', 'cp39-cp39']
if pm.machine() in ['x86_64', 'AMD64', 'x86']:
if machine_arch in ['x86_64', 'AMD64', 'x86']:
python_abi_tags += ['cp27-cp27m', 'pp27-pypy_73', 'pp36-pypy36_pp73', 'pp37-pypy37_pp73']
if platform == 'linux':
@@ -105,9 +109,9 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
platform_tags = []
if platform == 'linux':
architectures = [pm.machine()]
architectures = [machine_arch]
if pm.machine() == 'x86_64' and python_abi_tag.startswith('cp'):
if machine_arch == 'x86_64' and python_abi_tag.startswith('cp'):
architectures.append('i686')
platform_tags = [
@@ -131,8 +135,9 @@ def expected_wheels(package_name, package_version, manylinux_versions=None,
for platform_tag in platform_tags:
wheels.append(f'{package_name}-{package_version}-{python_abi_tag}-{platform_tag}.whl')
if IS_WINDOWS_RUNNING_ON_TRAVIS:
# Python 2.7 isn't supported on Travis.
# Travis on Windows does not support using the default Python 2.7 compiler,
# so we support skipping here.
if exclude_27:
wheels = [w for w in wheels if '-cp27-' not in w and '-pp2' not in w]
return wheels
+43
View File
@@ -0,0 +1,43 @@
import pytest
import toml
from cibuildwheel.util import resources_dir
Version = pytest.importorskip("packaging.version").Version
from cibuildwheel.extra import InlineArrayDictEncoder # noqa: E402
def test_compare_configs():
with open(resources_dir / "build-platforms.toml") as f:
txt = f.read()
dict_txt = toml.loads(txt)
new_txt = toml.dumps(dict_txt, encoder=InlineArrayDictEncoder())
print(new_txt)
assert new_txt == txt
def test_dump_with_Version():
example = {
"windows": {
"python_configurations": [
{"identifier": "cp27-win32", "version": Version("2.7.18"), "arch": "32"},
{"identifier": "cp27-win_amd64", "version": Version("2.7.18"), "arch": "64"},
]
}
}
result = """\
[windows]
python_configurations = [
{ identifier = "cp27-win32", version = "2.7.18", arch = "32" },
{ identifier = "cp27-win_amd64", version = "2.7.18", arch = "64" },
]
"""
output = toml.dumps(example, encoder=InlineArrayDictEncoder())
print(output)
assert output == result
+10
View File
@@ -59,3 +59,13 @@ def test_build_and_skip():
assert not build_selector('cp27-win_amd64')
assert build_selector('cp36-win_amd64')
assert not build_selector('cp37-win_amd64')
def test_build_braces():
build_selector = BuildSelector(build_config="cp{36,37}*", skip_config="")
assert not build_selector('cp27-manylinux1_x86_64')
assert build_selector('cp36-manylinux1_x86_64')
assert build_selector('cp37-manylinux1_x86_64')
assert not build_selector('cp38-manylinux1_x86_64')
assert not build_selector('cp39-manylinux1_x86_64')
+2 -2
View File
@@ -1,7 +1,7 @@
from cibuildwheel.util import DependencyConstraints
from pathlib import Path
from cibuildwheel.util import DependencyConstraints
def test_defaults():
dependency_constraints = DependencyConstraints.with_defaults()
+3 -3
View File
@@ -1,9 +1,9 @@
import certifi
import pytest
import ssl
from cibuildwheel.util import download
import certifi
import pytest
from cibuildwheel.util import download
DOWNLOAD_URL = 'https://raw.githubusercontent.com/joerick/cibuildwheel/v1.6.3/requirements-dev.txt'
+26 -8
View File
@@ -1,15 +1,11 @@
import platform as platform_module
import subprocess
import sys
from pathlib import Path
import pytest
from cibuildwheel import (
linux,
macos,
util,
windows,
)
from cibuildwheel import linux, macos, util, windows
class ArgsInterceptor:
@@ -56,19 +52,41 @@ def fake_package_dir(monkeypatch):
else:
return real_path_exists(path)
args = ['cibuildwheel', str(MOCK_PACKAGE_DIR)]
monkeypatch.setattr(Path, 'exists', mock_path_exists)
monkeypatch.setattr(sys, 'argv', ['cibuildwheel', str(MOCK_PACKAGE_DIR)])
monkeypatch.setattr(sys, 'argv', args)
return args
@pytest.fixture
def allow_empty(request, monkeypatch, fake_package_dir):
monkeypatch.setattr(sys, 'argv', fake_package_dir + ['--allow-empty'])
@pytest.fixture(params=['linux', 'macos', 'windows'])
def platform(request, monkeypatch):
platform_value = request.param
monkeypatch.setenv('CIBW_PLATFORM', platform_value)
if platform_value == 'windows':
monkeypatch.setattr(platform_module, 'machine', lambda: 'AMD64')
else:
monkeypatch.setattr(platform_module, 'machine', lambda: 'x86_64')
return platform_value
@pytest.fixture
def intercepted_build_args(platform, monkeypatch):
intercepted = ArgsInterceptor()
monkeypatch.setattr(globals()[platform], 'build', intercepted)
if platform == 'linux':
monkeypatch.setattr(linux, 'build', intercepted)
elif platform == 'macos':
monkeypatch.setattr(macos, 'build', intercepted)
elif platform == 'windows':
monkeypatch.setattr(windows, 'build', intercepted)
else:
raise ValueError(f'unknown platform value: {platform}')
return intercepted
+11 -3
View File
@@ -8,7 +8,6 @@ from cibuildwheel.__main__ import main
from cibuildwheel.environment import ParsedEnvironment
from cibuildwheel.util import BuildSelector
# CIBW_PLATFORM is tested in main_platform_test.py
@@ -41,7 +40,7 @@ def test_output_dir_argument(also_set_environment, platform, intercepted_build_a
assert intercepted_build_args.args[0].output_dir == OUTPUT_DIR
def test_build_selector(platform, intercepted_build_args, monkeypatch):
def test_build_selector(platform, intercepted_build_args, monkeypatch, allow_empty):
BUILD = 'some build* *-selector'
SKIP = 'some skip* *-selector'
@@ -58,6 +57,15 @@ def test_build_selector(platform, intercepted_build_args, monkeypatch):
# Unit tests for BuildSelector are in build_selector_test.py
def test_empty_selector(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_SKIP', '*')
with pytest.raises(SystemExit) as e:
main()
assert e.value.code == 3
@pytest.mark.parametrize('architecture, image, full_image', [
('x86_64', None, 'quay.io/pypa/manylinux2010_x86_64:*'),
('x86_64', 'manylinux1', 'quay.io/pypa/manylinux1_x86_64:*'),
@@ -221,7 +229,7 @@ def test_build_verbosity(build_verbosity, platform_specific, platform, intercept
('*-macosx_10_9_x86_64', ['*-macosx_x86_64']),
('cp37-macosx_10_9_x86_64', ['cp37-macosx_x86_64']),
])
def test_build_selector_migrations(intercepted_build_args, monkeypatch, option_name, option_value, build_selector_patterns):
def test_build_selector_migrations(intercepted_build_args, monkeypatch, option_name, option_value, build_selector_patterns, allow_empty):
monkeypatch.setenv(option_name, option_value)
main()
+80 -2
View File
@@ -1,10 +1,10 @@
import sys
import pytest
from conftest import MOCK_PACKAGE_DIR # noqa: I100
from cibuildwheel.__main__ import main
from conftest import MOCK_PACKAGE_DIR # noqa: I100
from cibuildwheel.util import Architecture
def test_unknown_platform_non_ci(monkeypatch, capsys):
@@ -64,3 +64,81 @@ def test_platform_environment(platform, intercepted_build_args, monkeypatch):
main()
assert intercepted_build_args.args[0].package_dir == MOCK_PACKAGE_DIR
def test_archs_default(platform, intercepted_build_args, monkeypatch):
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
assert build_options.architectures == {Architecture.x86_64, Architecture.i686}
elif platform == 'windows':
assert build_options.architectures == {Architecture.AMD64, Architecture.x86}
else:
assert build_options.architectures == {Architecture.x86_64}
@pytest.mark.parametrize('use_env_var', [False, True])
def test_archs_argument(platform, intercepted_build_args, monkeypatch, use_env_var):
if use_env_var:
monkeypatch.setenv('CIBW_ARCHS', 'ppc64le')
else:
monkeypatch.setenv('CIBW_ARCHS', 'unused')
monkeypatch.setattr(sys, 'argv', sys.argv + ['--archs', 'ppc64le'])
if platform in {'macos', 'windows'}:
with pytest.raises(SystemExit) as exit:
main()
assert exit.value.args == (4,)
else:
main()
build_options = intercepted_build_args.args[0]
assert build_options.architectures == {Architecture.ppc64le}
def test_archs_platform_specific(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'unused')
monkeypatch.setenv('CIBW_ARCHS_LINUX', 'ppc64le')
monkeypatch.setenv('CIBW_ARCHS_WINDOWS', 'x86')
monkeypatch.setenv('CIBW_ARCHS_MACOS', 'x86_64')
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
assert build_options.architectures == {Architecture.ppc64le}
elif platform == 'windows':
assert build_options.architectures == {Architecture.x86}
elif platform == 'macos':
assert build_options.architectures == {Architecture.x86_64}
def test_archs_platform_native(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'native')
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
assert build_options.architectures == {Architecture.x86_64}
elif platform == 'windows':
assert build_options.architectures == {Architecture.AMD64}
elif platform == 'macos':
assert build_options.architectures == {Architecture.x86_64}
def test_archs_platform_all(platform, intercepted_build_args, monkeypatch):
monkeypatch.setenv('CIBW_ARCHS', 'all')
main()
build_options = intercepted_build_args.args[0]
if platform == 'linux':
assert build_options.architectures == {Architecture.x86_64, Architecture.i686, Architecture.aarch64, Architecture.ppc64le, Architecture.s390x}
elif platform == 'windows':
assert build_options.architectures == {Architecture.x86, Architecture.AMD64}
elif platform == 'macos':
assert build_options.architectures == {Architecture.x86_64}