forked from rism-digital/verovio
-
Notifications
You must be signed in to change notification settings - Fork 0
297 lines (254 loc) · 9.5 KB
/
python-ci-wheel.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
name: Python Wheel Build
on:
push:
# Trigger the workflow on push, but only for the develop-pypi and master branch
branches: [develop-pypi, master]
# globals
env:
PACKAGE_NAME: verovio
CHECK_INSTALL_DIR: check_install_dir
CIBW_BUILD_IDENTIFIER: ""
jobs:
#===============================================#
# BUILD WHEEL DISTRIBUTION #
#===============================================#
build_wheels:
name: Build wheels (${{ matrix.python-version }}, ${{ matrix.os }}-${{ matrix.architecture }})
runs-on: ${{ matrix.os }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
# Build the wheels for Linux, Windows and macOS
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
architecture: [x86, x64, arm64]
include:
- os: macos-latest
architecture: x64
platform_id: macosx_*
- os: windows-latest
architecture: x64
platform_id: win_amd64
- os: windows-latest
architecture: x86
platform_id: win32
- os: ubuntu-latest
architecture: x64
platform_id: manylinux_x86_64
- os: ubuntu-latest
architecture: aarch64
platform_id: manylinux_aarch64
exclude:
- os: macos-latest
architecture: arm64
- os: macos-latest
architecture: x86
- os: windows-latest
architecture: arm64
- os: ubuntu-latest
architecture: x86
steps:
#===============================================#
# Set up
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nuget/setup-nuget@v1
with:
nuget-version: "latest"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
#===============================================#
# Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install importlib_resources twine
#===============================================#
# Prepare identifier
- name: Set CIBW_BUILD_IDENTIFIER
shell: bash
run: |
# Remove dot from python-version for CIBW and prefix with cp
id=cp$(echo ${{ matrix.python-version }} | sed -e 's/\.//g')-${{ matrix.platform_id }}
echo CIBW_BUILD_IDENTIFIER=$id >> $GITHUB_ENV
echo $id
#===============================================#
# wheels
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: wheelhouse
env:
CIBW_SKIP: cp38-win_arm64
CIBW_BUILD: ${{ env.CIBW_BUILD_IDENTIFIER }}
CIBW_ARCHS_LINUX: "auto aarch64"
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_MACOS: brew update && brew install swig
CIBW_BEFORE_ALL_WINDOWS: choco install swig -f -y
CIBW_BEFORE_BUILD: swig -version && bash -c 'cd tools; ./get_git_commit.sh' && swig -c++ -python -py3 ./bindings/python/verovio.i
CMAKE_BUILD_PARALLEL_LEVEL: 12
#===============================================#
# Check build
# TODO: Can be removed when everything is set up
- name: "List result"
working-directory: wheelhouse
run: ls -R
- name: Check with Twine
working-directory: wheelhouse
run: twine check *.whl
- name: Install from wheel on Linux
if: always() && runner.os == 'Linux'
working-directory: wheelhouse
run: python -m pip install ./*.whl
# Install only the x86_64 wheel on macOS
- name: Install from wheel on macOS
working-directory: wheelhouse
if: always() && runner.os == 'macOS'
run: python -m pip install ./*x86_64.whl
# Wildcard use is different with PowerShell
# cf. https://stackoverflow.com/a/43900040
- name: Install from wheel on Windows
working-directory: wheelhouse
if: always() && runner.os == 'Windows'
run: python -m pip install (get-item .\*.whl).FullName
- name: Check wheel installation
working-directory: wheelhouse
run: python -c "import verovio; tk = verovio.toolkit(); v = tk.getVersion(); print('verovio.toolkit.getVersion():', v)"
#===============================================#
# Upload artifacts
- uses: actions/upload-artifact@v3
with:
name: cibuildwheel-${{ runner.os }}-python-${{ matrix.python-version }}
path: ./wheelhouse/*.whl
#===============================================#
# BUILD SOURCE DISTRIBUTION #
#===============================================#
build_sdist:
name: Build sdist
runs-on: [ubuntu-latest]
steps:
#===============================================#
# Set up
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.9"
#===============================================#
# Swig
- name: Install swig
if: runner.os == 'Linux'
run: |
sudo apt update -q
sudo apt install swig
- name: Verify swig
run: swig -version
#===============================================#
# Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine
#===============================================#
# sdist
- name: Build ext
run: python setup.py build_ext
- name: Build source distribution
run: python setup.py sdist
#===============================================#
# Check build
# TODO: Can be removed when everything is set up
- name: List result
working-directory: dist
run: ls -R
- name: Check with Twine
working-directory: dist
run: twine check *.tar.gz
- name: Create install dir
shell: bash
run: mkdir - p ${{ env.CHECK_INSTALL_DIR }}
- name: Install from source
working-directory: ${{ env.CHECK_INSTALL_DIR }}
run: python -m pip install ../dist/*.tar.gz
- name: Check source installation
working-directory: ${{ env.CHECK_INSTALL_DIR }}
run: python -c "import verovio; tk = verovio.toolkit(); v = tk.getVersion(); print('verovio.toolkit.getVersion():', v)"
#===============================================#
# Upload artifact
- uses: actions/upload-artifact@v3
with:
name: sdist-${{ runner.os }}-python-3.9
path: dist/*.tar.gz
#===============================================#
# UPLOAD TO PACKAGE INDEX #
#===============================================#
upload_testpypi:
name: Upload to TestPyPi
needs: [build_wheels, build_sdist]
runs-on: [ubuntu-latest]
steps:
#===============================================#
# Set up
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
architecture: "x64"
#===============================================#
# Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install twine
#===============================================#
# Prepare artifacts
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bindings/python/artifacts/
# TODO: Can be removed when everything is set up
- name: Display structure of downloaded files
working-directory: bindings/python/artifacts/
run: ls -R
- name: Copy artifacts to dist folder
working-directory: bindings/python/
run: |
mkdir -p ./dist
cp artifacts/*/* dist/
# TODO: Can be removed when everything is set up
- name: Verify dist folder
working-directory: bindings/python/dist/
run: ls -R
#===============================================#
# Upload to package test index
- name: Upload to TestPyPi
working-directory: bindings/python
env:
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
run: twine upload --repository testpypi dist/*
#===============================================#
# Check test build
- name: Create install dir
shell: bash
run: |
mkdir - p ${{ env.CHECK_INSTALL_DIR }}
cd ${{ env.CHECK_INSTALL_DIR }}
python -m pip install --index-url https://test.pypi.org/simple/ --pre ${{ env.PACKAGE_NAME }}
python -c "import verovio; tk = verovio.toolkit(); v = tk.getVersion(); print('verovio.toolkit.getVersion():', v)"