Skip to content

Commit 20febe0

Browse files
authored
Use cibuildwheel to build wheels (#435)
1 parent a62f781 commit 20febe0

File tree

4 files changed

+34
-151
lines changed

4 files changed

+34
-151
lines changed

.github/workflows/build-manylinux-wheels.sh

-28
This file was deleted.

.github/workflows/release.yml

+33-116
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
mkdir -p dist/
3838
echo "${VERSION}" > dist/VERSION
3939
40-
- uses: actions/upload-artifact@v1
40+
- uses: actions/upload-artifact@v2
4141
with:
4242
name: dist
4343
path: dist/
@@ -47,172 +47,89 @@ jobs:
4747
runs-on: ubuntu-latest
4848

4949
steps:
50-
- uses: actions/checkout@v1
50+
- uses: actions/checkout@v2
5151
with:
5252
fetch-depth: 50
5353
submodules: true
5454

55-
- name: Set up Python 3.7
56-
uses: actions/setup-python@v1
57-
with:
58-
python-version: 3.7
55+
- uses: actions/setup-python@v2
5956

6057
- name: Build source distribution
6158
run: |
62-
pip install -U setuptools wheel pip
59+
python -m pip install -U setuptools wheel pip
6360
python setup.py sdist
6461
65-
- uses: actions/upload-artifact@v1
62+
- uses: actions/upload-artifact@v2
6663
with:
6764
name: dist
68-
path: dist/
65+
path: dist/*.tar.*
6966

7067
build-wheels:
7168
needs: validate-release-request
7269
runs-on: ${{ matrix.os }}
7370
strategy:
7471
matrix:
75-
python-version: [3.7, 3.8, 3.9]
76-
os: [ubuntu-20.04, macos-latest]
77-
arch: [x86_64, aarch64]
72+
os: [ubuntu-latest, macos-latest]
73+
cibw_python: ["cp37-*", "cp38-*", "cp39-*", "cp310-*"]
74+
cibw_arch: ["x86_64", "aarch64", "universal2"]
7875
exclude:
76+
- os: ubuntu-latest
77+
cibw_arch: universal2
7978
- os: macos-latest
80-
arch: aarch64
79+
cibw_arch: aarch64
80+
- os: macos-latest
81+
cibw_python: "cp37-*"
82+
cibw_arch: universal2
8183

8284
defaults:
8385
run:
8486
shell: bash
8587

8688
steps:
87-
- uses: actions/checkout@v1
89+
- uses: actions/checkout@v2
8890
with:
8991
fetch-depth: 50
9092
submodules: true
9193

92-
- uses: actions/download-artifact@v1
93-
with:
94-
name: dist
95-
path: dist/
96-
97-
- name: Extract Release Version
98-
id: relver
99-
run: |
100-
set -e
101-
echo ::set-output name=version::$(cat dist/VERSION)
102-
rm dist/*
103-
10494
- name: Set up QEMU
105-
if: matrix.arch == 'aarch64'
95+
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
10696
uses: docker/setup-qemu-action@v1
107-
108-
- name: Set up Python ${{ matrix.python-version }}
109-
uses: actions/setup-python@v1
11097
with:
111-
python-version: ${{ matrix.python-version }}
112-
113-
- name: Install Python deps
114-
run: |
115-
python -m pip install --upgrade setuptools pip wheel
98+
platforms: arm64
11699

117100
- name: Install macOS deps
118101
if: startsWith(matrix.os, 'macos')
119102
run: |
120103
brew install gnu-sed libtool autoconf automake
121104
122-
- name: Build Wheels (linux)
123-
if: startsWith(matrix.os, 'ubuntu')
124-
env:
125-
PYTHON_VERSION: ${{ matrix.python-version }}
126-
ARCH: ${{ matrix.arch }}
127-
run: |
128-
case "${ARCH}" in
129-
x86_64)
130-
mlimg=manylinux2010_x86_64
131-
;;
132-
aarch64)
133-
mlimg=manylinux2014_aarch64
134-
;;
135-
*)
136-
echo "Unsupported wheel arch: ${ARCH}" >&2
137-
exit 1
138-
;;
139-
esac
140-
141-
docker run --rm \
142-
-v "${GITHUB_WORKSPACE}":/github/workspace:rw \
143-
--workdir=/github/workspace \
144-
-e GITHUB_WORKSPACE=/github/workspace \
145-
-e PYTHON_VERSION="${PYTHON_VERSION}" \
146-
--entrypoint=/github/workspace/.github/workflows/build-manylinux-wheels.sh \
147-
quay.io/pypa/${mlimg}
148-
149-
- name: Build Wheels (non-linux)
150-
if: "!startsWith(matrix.os, 'ubuntu')"
151-
run: |
152-
make clean
153-
python setup.py bdist_wheel
154-
155-
- name: Test Wheels (native)
156-
timeout-minutes: 10
157-
if: |
158-
!contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
159-
&& matrix.arch == 'x86_64'
105+
- uses: pypa/[email protected]
160106
env:
161-
OS: ${{ matrix.os }}
162-
PKG_VERSION: ${{ steps.relver.outputs.version }}
163-
run: |
164-
"${GITHUB_WORKSPACE}/.github/workflows/test-wheels.sh"
165-
166-
- name: Test Wheels (emulated)
167-
timeout-minutes: 30
168-
if: |
169-
!contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
170-
&& matrix.arch != 'x86_64'
171-
env:
172-
PYTHON_VERSION: ${{ matrix.python-version }}
173-
ARCH: ${{ matrix.arch }}
174-
PKG_VERSION: ${{ steps.relver.outputs.version }}
175-
run: |
176-
case "${ARCH}" in
177-
aarch64)
178-
img="docker.io/arm64v8/python:${PYTHON_VERSION}-buster"
179-
;;
180-
*)
181-
echo "Unsupported wheel arch: ${ARCH}" >&2
182-
exit 1
183-
;;
184-
esac
185-
186-
docker run --rm \
187-
-v "${GITHUB_WORKSPACE}":/github/workspace:rw \
188-
-e GITHUB_WORKSPACE=/github/workspace \
189-
-e PKG_VERSION="${PKG_VERSION}" \
190-
--workdir=/github/workspace/ \
191-
${img} \
192-
/bin/bash -ex -c ' \
193-
echo GITHUB_WORKSPACE=${GITHUB_WORKSPACE} >> /etc/environment \
194-
&& echo PKG_VERSION=${PKG_VERSION} >> /etc/environment \
195-
&& echo ENVIRON_FILE /etc/environment >> /etc/login.defs \
196-
&& useradd -m -s /bin/bash test \
197-
&& su -l test /github/workspace/.github/workflows/test-wheels.sh \
198-
'
199-
200-
- uses: actions/upload-artifact@v1
107+
CIBW_BUILD_VERBOSITY: 1
108+
CIBW_BUILD: ${{ matrix.cibw_python }}
109+
CIBW_ARCHS: ${{ matrix.cibw_arch }}
110+
CIBW_TEST_EXTRAS: "test"
111+
CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py"
112+
CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py"
113+
CIBW_TEST_SKIP: "*universal2:arm64"
114+
# This is needed for now because cffi has no cp310 wheels
115+
CIBW_BEFORE_BUILD_LINUX: "yum -y install libffi-devel"
116+
117+
- uses: actions/upload-artifact@v2
201118
with:
202119
name: dist
203-
path: dist/
120+
path: wheelhouse/*.whl
204121

205122
publish:
206123
needs: [build-sdist, build-wheels]
207124
runs-on: ubuntu-latest
208125

209126
steps:
210-
- uses: actions/checkout@v1
127+
- uses: actions/checkout@v2
211128
with:
212129
fetch-depth: 5
213130
submodules: false
214131

215-
- uses: actions/download-artifact@v1
132+
- uses: actions/download-artifact@v2
216133
with:
217134
name: dist
218135
path: dist/

.github/workflows/test-wheels.sh

-7
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ uvloop/loop.*.pyd
3333
/.vscode
3434
/.eggs
3535
/.venv*
36+
/wheelhouse

0 commit comments

Comments
 (0)