-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (102 loc) · 3.64 KB
/
build-wheels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
name: Build Wheels
on:
workflow_dispatch:
jobs:
Standard:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-11.0, windows-latest, ubuntu-latest]
architecture: [x64]
include:
- os: windows-latest
architecture: x86
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: ${{ matrix.architecture }}
- name: Install clang
if: startsWith(matrix.os, 'windows')
uses: bwoodsend/setup-winlibs-action@v1
with:
architecture: ${{ matrix.architecture }}
with_clang: true
# Compile with clang by default which produces faster binaries.
- run: echo CC=clang >> $GITHUB_ENV
# macOS needs special compiler flags to enable 'universal2' binaries.
- if: startsWith(matrix.os, 'macos')
run: echo CC_FLAGS='-arch x86_64 -arch arm64' >> $GITHUB_ENV
# Check the compiler. Don't fail if CC isn't set.
- run: ${CC:-echo} -v
shell: bash
- run: pip wheel --no-deps -w dist .
# Build a universal2 wheel for macOS to support both arm64 and x86_64.
# Hopefully I'll think of a better way to do this and add it to cslug.
- if: startsWith(matrix.os, 'macos')
run: |
mv dist/*.whl "dist/$(ls dist/ | sed 's/x86_64/universal2/')"
# Build a wheel for modern x86_64 Linux using clang (which produces
# a faster binary than gcc).
- if: startsWith(matrix.os, 'ubuntu')
run: |
pip install auditwheel
export OLD_WHEEL="$(echo dist/*.whl)"
# When glibc on CI updates, update the manylinux variant as needed.
auditwheel repair "$OLD_WHEEL" --plat=manylinux2014_x86_64 -w dist
rm $OLD_WHEEL
- name: Upload wheel(s) as build artifacts
uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.os }}-${{ matrix.architecture }}
path: dist/*.whl
- name: Test Wheel
run: |
pip install "$(echo dist/*.whl)[test]" &&
rm -rf hirola &&
pytest --no-cov
shell: bash
Whacky-Linux:
runs-on: ubuntu-latest
strategy:
matrix:
base: [
manylinux1_x86_64,
manylinux1_i686,
manylinux2014_aarch64,
# Support these when NumPy provides wheels for them.
# manylinux2014_ppc64le,
# manylinux2014_s390x,
]
steps:
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install -y qemu-user-static
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes
- name: Build docker image
run: |
docker build -t bob-the-builder --build-arg BASE=${{ matrix.base }} .
- name: Build wheel
run: |
docker run -v "$(pwd):/io" bob-the-builder bash -c "
rm -rf build /tmp/dist
python setup.py -q bdist_wheel -d /tmp/dist
auditwheel repair /tmp/dist/*.whl -w dist
"
- name: Upload wheel(s) as build artifacts
uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.base }}
path: dist/*.whl
- name: Install and test wheel
run: |
docker run -v "$(pwd)/tests:/tests" -v "$(pwd)/dist:/dist" \
-t bob-the-builder bash -c "
cd ~ &&
pip uninstall -y hirola &&
# Note that this assumes that there is only one wheel in dist.
pip install /dist/hirola*manylinux*.whl &&
pytest /tests
"