-
Notifications
You must be signed in to change notification settings - Fork 42
237 lines (226 loc) · 9.36 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
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
# GitHub Workflow to build, test, and upload wheels
# TODO: Implement GitHub's caching to speed up builds
# TODO: Decide on specific versions of dependencies, and our pinning strategy
# TODO: Implement ARM-based macOS builds on a self-hosted runner
# TODO: Raspberry Pi builds
# TODO: Linting
name: Wheel Builder
on: [push, pull_request]
jobs:
build_wheels:
name: Build for ${{ matrix.cibw-build }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# - os: windows-latest
# python-version: 3.8
# cibw-build: cp38-win_amd64
# - os: windows-latest
# python-version: 3.9
# cibw-build: cp39-win_amd64
# - os: windows-latest
# python-version: '3.10'
# cibw-build: cp310-win_amd64
# - os: windows-latest
# python-version: 3.11
# cibw-build: cp311-win_amd64
- os: ubuntu-latest
python-version: 3.8
cibw-build: cp38-manylinux_x86_64
- os: ubuntu-latest
python-version: 3.9
cibw-build: cp39-manylinux_x86_64
- os: ubuntu-latest
python-version: '3.10'
cibw-build: cp310-manylinux_x86_64
- os: ubuntu-latest
python-version: 3.11
cibw-build: cp311-manylinux_x86_64
# - os: macos-latest
# python-version: 3.8
# cibw-build: cp38-macosx_x86_64
# - os: macos-latest
# python-version: 3.9
# cibw-build: cp39-macosx_x86_64
# - os: macos-latest
# python-version: '3.10'
# cibw-build: cp310-macosx_x86_64
# - os: macos-latest
# python-version: 3.11
# cibw-build: cp311-macosx_x86_64
# I have no idea how to use the ARM runners on GitHub. Supposedly they exist but I can't figure them out.
# So for now we'll just manually build and upload Apple Silicon wheels? Last updated Oct 2 2023
# - os: macos-13-arm64
# python-version: 3.8
# cibw-build: cp38-macosx_universal2
# - os: macos-13-arm64
# python-version: 3.9
# cibw-build: cp39-macosx_universal2
# - os: macos-13-arm64
# python-version: '3.10'
# cibw-build: cp310-macosx_universal2
# - os: macos-13-arm64
# python-version: 3.11
# cibw-build: cp311-macosx_universal2
steps:
- name: Checkout MPF-MC
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run cibuildwheel
uses: pypa/[email protected] # Oct 2, 2023
env:
CIBW_BEFORE_ALL_LINUX: > # This is done here and not as its own step as this runs inside the cibw containered environment
yum install -y SDL2.x86_64 SDL2-devel.x86_64 SDL2_image.x86_64 SDL2_image-devel.x86_64
SDL2_mixer.x86_64 SDL2_mixer-devel.x86_64 gstreamer1.x86_64 gstreamer1-devel.x86_64 &&
python -m pip install --upgrade pip &&
pip install --upgrade setuptools wheel build &&
git clone --recursive --branch ${{ github.ref_name }} https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch `python get_version.py` https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch dev https://github.com/missionpinball/mpf.git _mpf &&
pip install -e _mpf
CIBW_BEFORE_ALL_MACOS: >
brew install SDL2 SDL2_mixer SDL2_image SDL2_ttf gstreamer
CIBW_BEFORE_ALL: >
python -m pip install --upgrade pip &&
pip install --upgrade setuptools wheel build &&
git clone --recursive --branch ${{ github.ref_name }} https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch `python get_version.py` https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch dev https://github.com/missionpinball/mpf.git _mpf &&
pip install -e _mpf
CIBW_BUILD: ${{ matrix.cibw-build }}
CIBW_BUILD_VERBOSITY: 3
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: mpf-mc_wheels
path: ./wheelhouse/*.whl
make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- name: Check out MPF-MC
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build SDist
run: >
sudo apt-get update &&
sudo apt-get -y remove libunwind-14 &&
sudo apt-get -y install libunwind-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev
gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad
gstreamer1.0-plugins-ugly libgstreamer1.0-dev &&
pip install --upgrade setuptools wheel build &&
python -m build --sdist
- name: Upload SDist
uses: actions/upload-artifact@v3
with:
name: mpf-mc_wheels
path: dist/*.tar.gz
test_wheels:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: [build_wheels]
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, '3.10', 3.11]
#os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
include:
- os: ubuntu-latest
python-version: 3.11
run-tests: true
runs-on: ${{ matrix.os }}
env:
DISPLAY: ':99.0'
steps:
- name: Install runtime libraries on macOS
if: runner.os == 'macOS'
run: brew install SDL2 SDL2_mixer gstreamer
- name: Install runtime libraries on Linux
if: runner.os == 'linux'
run: |
sudo apt-get update
sudo apt-get -y install libsdl2-2.0 libsdl2-mixer-2.0 gstreamer-1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly xvfb
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install runtime dependencies via pip
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel coveralls prospector==1.3.1
- name: Download the newly-built wheel
uses: actions/download-artifact@v3
with:
name: mpf-mc_wheels
path: dist
- name: Clone & install MPF # try to find a matching version before we default to dev
run: >
git clone --recursive --branch ${{ github.ref_name }} https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch `python get_version.py` https://github.com/missionpinball/mpf.git _mpf ||
git clone --recursive --branch dev https://github.com/missionpinball/mpf.git _mpf &&
pip install -e _mpf
- name: List wheels in dist
run: ls -l dist
- name: Install MPF-MC from new wheel
shell: bash # Need bash on windows to use the if statement
# We need some logic here to force pip to use the new wheel we just built. Otherwise if we're on a pull request, it will try to install from pypi which won't test the new wheel.
# We can't use --no-index because we need to install the rest of the dependencies from pypi
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
platform="manylinux_2_17_x86_64.manylinux2014_x86_64"
elif [ "${{ runner.os }}" == "macOS" ]; then
platform="macosx_10_9_x86_64"
elif [ "${{ runner.os }}" == "Windows" ]; then
platform="win_amd64"
fi
python_version_nodot=$(echo "${{ matrix.python-version }}" | tr -d '.')
wheel_file=$(ls dist/mpf_mc-*cp${python_version_nodot}-*-${platform}.whl)
pip install "$wheel_file"
- name: Run tests # Can't figure out how to run tests on mac or windows, but I guess that's ok? At least we test the wheel installs? TODO?
if: ${{ matrix.run-tests }}
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1280x720x24 -ac +extension GLX
coverage3 run --concurrency=thread -m unittest discover -v mpfmc.tests
coverage3 run -a --concurrency=thread -m unittest discover -v mpfmc.integration
- name: Upload coverage data to coveralls.io
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}-${{ matrix.os }}
COVERALLS_PARALLEL: true
publish_to_pypi: # only if this release has a tag and is a push from us (e.g. not a pull request)
name: Publish to PYPI
needs: [test_wheels, make_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
environment:
name: pypi
url: https://pypi.org/p/mpf
permissions:
id-token: write
steps:
- name: Download wheels
uses: actions/download-artifact@v3
with:
name: mpf-mc_wheels
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
coveralls:
name: Finalize Coveralls
needs: test_wheels
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}