-
Notifications
You must be signed in to change notification settings - Fork 8
290 lines (246 loc) · 8.89 KB
/
build.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
name: Build and publish
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
jobs:
upload:
name: Upload to PyPI
if: github.repository == 'micro-manager/pymmcore'
runs-on: ubuntu-latest
needs: [sdist, wheels-manylinux, wheels-winmac]
steps:
- name: Download wheels and sdist
uses: actions/download-artifact@v3
- name: Collect wheels and sdist
run: |
mkdir dist
mv pymmcore-sdist/* dist/
mv pymmcore-wheels-manylinux/* dist/
mv pymmcore-wheels-win-mac/* dist/
ls dist
- name: Upload release to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
sdist:
name: sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: |
git submodule sync --recursive
git submodule update --init --force --recursive --depth=1
- name: Install tools and dependencies
run: |
sudo apt-get install -y python3-dev python3-pip python3-venv
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip build
- name: Create source distribution
run: |
source venv/bin/activate
python -m build --sdist --outdir dist/ .
- uses: actions/upload-artifact@v3
with:
name: pymmcore-sdist
path: dist
wheels-manylinux:
strategy:
fail-fast: true
matrix:
manylinux-version: ['2014']
arch: [i686, x86_64]
include:
- arch: i686
numpy-versions: cp38-cp38 1.17.3 cp39-cp39 1.19.3
- arch: x86_64
numpy-versions: cp38-cp38 1.17.3 cp39-cp39 1.19.3 cp310-cp310 1.21.3 cp311-cp311 1.23.2
name: manylinux${{ matrix.manylinux-version }}_${{ matrix.arch }}
runs-on: ubuntu-latest
env:
AUDITWHEEL_PLAT: manylinux${{ matrix.manylinux-version }}_${{ matrix.arch }}
DOCKER_IMAGE: quay.io/pypa/manylinux${{ matrix.manylinux-version }}_${{ matrix.arch }}
NUMPY_VERSIONS: ${{ matrix.numpy-versions }}
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: |
git submodule sync --recursive
git submodule update --init --force --recursive --depth=1
- name: Pull image
run: |
docker pull $DOCKER_IMAGE
- name: Build
run: |
docker run -e NUMPY_VERSIONS -e AUDITWHEEL_PLAT -v $(pwd):/io $DOCKER_IMAGE /io/manylinux/build.sh
- uses: actions/upload-artifact@v3
with:
name: pymmcore-wheels-manylinux
path: wheelhouse
wheels-winmac:
strategy:
fail-fast: true
matrix:
os: [Windows, macOS]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-arch: [x64, x86]
macos-deployment-target: ['10.9']
msvc-version: ['14.1'] # VS2017
include:
- os: Windows
runner: windows-latest
- os: macOS
runner: macOS-latest
- python-version: '3.8'
mac-python-version: 3.8.10
mac-python-installer-macos-version: macosx10.9
numpy-version: 1.17.3
- python-version: '3.9'
mac-python-version: 3.9.7
mac-python-installer-macos-version: macosx10.9
numpy-version: 1.19.3
- python-version: '3.10'
mac-python-version: 3.10.0
mac-python-installer-macos-version: macos11
numpy-version: 1.21.3
- python-version: '3.11'
mac-python-version: 3.11.0
mac-python-installer-macos-version: macos11
numpy-version: 1.23.2
- python-arch: x64
msvc-arch: amd64
- python-arch: x86
msvc-arch: x86
exclude:
- os: macOS
python-arch: x86
- os: Windows # NumPy has 64-bit only for Windows wheels >= cp310
python-version: '3.10'
python-arch: x86
name: ${{ matrix.os }} Python ${{ matrix.python-version }} ${{ matrix.python-arch }}
runs-on: ${{ matrix.runner }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos-deployment-target }}
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: |
git submodule sync --recursive
git submodule update --init --force --recursive --depth=1
- name: Find Visual Studio (Windows)
if: matrix.os == 'Windows'
shell: pwsh
run: |
$VsDir = (& "${Env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere" -latest -property installationPath)
echo "VCVARSALL_DIR=$VsDir/VC/Auxiliary/Build" >>$Env:GITHUB_ENV
- name: Install Python (generic)
uses: actions/setup-python@v4
if: matrix.os != 'macOS'
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.python-arch }}
- name: Install Python (macOS)
if: matrix.os == 'macOS'
run: |
curl -L -o python.pkg https://www.python.org/ftp/python/${{ matrix.mac-python-version }}/python-${{ matrix.mac-python-version }}-${{ matrix.mac-python-installer-macos-version }}.pkg
sudo installer -pkg python.pkg -target /
/Library/Frameworks/Python.framework/Versions/${{ matrix.python-version }}/bin/python3 -m venv venv
- name: Install tools (Windows)
if: matrix.os == 'Windows'
run: |
choco install -y swig
- name: Install tools (macOS)
if: matrix.os == 'macOS'
run: |
brew install swig
- name: Install dependencies (Windows)
if: matrix.os == 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python -m pip install numpy==${{ matrix.numpy-version }}
- name: Install dependencies (Unix)
if: matrix.os != 'Windows'
run: |
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python -m pip install numpy==${{ matrix.numpy-version }}
- name: Package and extract sources (Windows)
if: matrix.os == 'Windows'
run: |
python setup.py sdist --format=zip
mkdir tmp
Expand-Archive -Path dist/pymmcore-*.zip -DestinationPath tmp
mv tmp/pymmcore-* tmp/pymmcore
- name: Package and extract sources (Unix)
if: matrix.os == 'macOS'
run: |
source venv/bin/activate
python setup.py sdist
mkdir tmp
tar xvzf dist/pymmcore-*.tar.gz -C tmp
mv tmp/pymmcore-* tmp/pymmcore
- name: Build wheel (Windows)
if: matrix.os == 'Windows'
shell: cmd
env:
MSSdk: 1
DISTUTILS_USE_SDK: 1
PY_VCRUNTIME_REDIST: 1
run: |
pushd "%VCVARSALL_DIR%"
call vcvarsall.bat ${{ matrix.msvc-arch }} -vcvars_ver=${{ matrix.msvc-version }}
popd
cd tmp\pymmcore
python setup.py build_ext
python setup.py build
python setup.py bdist_wheel
- name: Build wheel (macOS)
if: matrix.os == 'macOS'
env:
CC: clang
CXX: clang++
CFLAGS: -fvisibility=hidden -Wno-unused-variable
run: |
source venv/bin/activate
cd tmp/pymmcore
python setup.py build_ext -j2
python setup.py build
python setup.py bdist_wheel
- name: Log undefined symbols (macOS)
if: matrix.os == 'macOS'
run: |
cd tmp/pymmcore
PYMOD=$(echo build/lib.*/pymmcore/_pymmcore_swig.*.so)
echo "$PYMOD:"
echo 'Weak symbols:'
nm -mu $PYMOD |c++filt |grep ' weak ' # This is never empty
echo '-- end of weak symbols --'
echo 'Undefined symbols not containing Py:'
nm -mu $PYMOD |c++filt |grep 'dynamically looked up' |grep -v _Py && exit 1
echo '-- end of non-Py dynamically looked up symbols --'
- name: Smoke test (Windows)
if: matrix.os == 'Windows'
run: |
cd .. # Avoid picking up pymmcore.py from cwd
python -m pip install (Get-Item pymmcore/tmp/pymmcore/dist/pymmcore-*.whl).FullName
python pymmcore/smoketest/smoke.py
- name: Smoke test (Unix)
if: matrix.os != 'Windows'
run: |
source venv/bin/activate
cd .. # Avoid picking up pymmcore.py from cwd
python -m pip install pymmcore/tmp/pymmcore/dist/pymmcore-*.whl
python pymmcore/smoketest/smoke.py
- uses: actions/upload-artifact@v3
with:
name: pymmcore-wheels-win-mac
path: tmp/pymmcore/dist