forked from refnx/refnx
-
Notifications
You must be signed in to change notification settings - Fork 0
378 lines (312 loc) · 12.1 KB
/
Copy pathpythonpackage.yml
File metadata and controls
378 lines (312 loc) · 12.1 KB
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
name: Test
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
###############################################################################
test_linux:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: ['3.12', '3.13', '3.14']
os: [ubuntu-24.04, ubuntu-24.04-arm]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
allow-prereleases: true
- name: Setup apt dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends qt6-base-dev build-essential
- name: Make wheel
env:
MPLBACKEND: agg
run: |
python -m pip install --upgrade pip
python -m pip install meson-python ninja meson wheel build auditwheel abi3audit
python -m build
auditwheel repair dist/*.whl
abi3audit --strict --report dist/refnx*.whl
- name: Install package and test with pytest
run: |
python -m pip install wheelhouse/*.whl
pip install -r .requirements.txt
export QT_QPA_PLATFORM=offscreen
pushd tools
pytest --pyargs refnx
popd
# check that refnx gui starts
# python tools/app/check_app_starts.py refnx
# run vendored ptemcee tests
pytest --pyargs refnx._lib.ptemcee.tests
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: refnx-wheel-${{ matrix.os }}-${{ matrix.python-version }}
path: wheelhouse/
###############################################################################
check_cibuildwheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: build wheel
uses: pypa/cibuildwheel@ee02a1537ce3071a004a6b08c41e72f0fdc42d9a # v3.4.0
env:
CIBW_TEST_COMMAND: pytest --pyargs refnx.reflect.tests.test_reflect
CIBW_BUILD: "cp311-manylinux_x86_64"
###############################################################################
test_macos:
runs-on: macos-15
strategy:
fail-fast: true
max-parallel: 3
matrix:
python-version: ['3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- run: mkdir -p dist
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
allow-prereleases: true
- name: install compilers
shell: bash
run: |
brew install llvm libomp
- name: Make wheel
shell: bash
run: |
export PATH="$PATH:/opt/homebrew/opt/llvm/bin"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib"
python -m pip install --upgrade pip
python -m pip install wheel delocate build abi3audit
python -m build . -v
# so that libomp is distributed with wheel
delocate-wheel -v dist/refnx*.whl
abi3audit --strict --report dist/refnx*.whl
- name: Install package and test with pytest
shell: bash
env:
QT_QPA_PLATFORM: offscreen
run: |
python -m pip install -r .requirements.txt
pushd dist
python -m pip install --only-binary=refnx --no-index --find-links=. refnx
pytest --pyargs refnx
popd
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: refnx-wheel-macos-${{ matrix.python-version }}
path: dist/
test_macos_app:
needs: test_macos
runs-on: macos-15
strategy:
fail-fast: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
allow-prereleases: true
- run: mkdir -p dist
- name: Download wheel
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: refnx-wheel-macos-3.12
merge-multiple: true
path: dist
- name: Make frozen GUI executable
run: |
# make app in virtualenv
python -m venv app
source app/bin/activate
python -m pip install --upgrade --upgrade-strategy eager -r tools/app/requirements.txt
python -m pip install scipy
pushd dist
ls
python -m pip install --only-binary=refnx --no-index --find-links=. refnx
popd
python -m pip install pyinstaller psutil
# compileall in an effort to speedup pyinstaller GUI start
python -m compileall
pushd tools/app
pyinstaller motofit.spec
# check to see that the app starts
python check_app_starts.py dist/refnx.app/Contents/MacOS/refnx
popd
printenv
- name: Sign app and create dmg
if: github.repository == 'refnx/refnx' && (github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags'))
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE_ISA }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_ISA_PWD }}
run: |
pushd tools/app
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
ls -al certificate.p12
security create-keychain -p DloaAcYP build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p DloaAcYP build.keychain
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k DloaAcYP build.keychain >/dev/null
security find-identity -p codesigning
codesign --verify --options=runtime --entitlements entitlements.plist --timestamp --deep --verbose=4 --force --sign "Developer ID Application: The International Scattering Alliance (8CX8K63BQM)" dist/refnx.app
cp ../../refnx/reflect/_app/icons/Motofit.icns .
sips -i Motofit.icns
DeRez -only icns Motofit.icns > icns.rsrc
hdiutil create dist/refnx.dmg -srcfolder dist/refnx.app -ov -format UDZO
Rez -append icns.rsrc -o dist/refnx.dmg
SetFile -a C dist/refnx.dmg
codesign -s "Developer ID Application: The International Scattering Alliance (8CX8K63BQM)" dist/refnx.dmg
mv dist/refnx.dmg ../../dist/
popd
# xcrun notarytool submit --apple-id "$APPLEID" --password "$APP_PASSWORD" --team-id 8CX8K63BQM --wait refnx.dmg
- name: Notarize DMG
if: github.repository == 'refnx/refnx' && (github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags'))
uses: lando/notarize-action@b5c3ef16cf2fbcf2af26dc58c90255ec242abeed # v2.0.2
with:
product-path: "dist/refnx.dmg"
primary-bundle-id: "com.refnx.refnx"
appstore-connect-username: ${{ secrets.NOTARIZATION_USERNAME }}
appstore-connect-password: ${{ secrets.NOTARIZATION_PASSWORD }}
appstore-connect-team-id: 8CX8K63BQM
verbose: True
- name: Staple Release Build
if: github.repository == 'refnx/refnx' && (github.event.pull_request.merged == true || startsWith(github.ref, 'refs/tags'))
uses: BoundfoxStudios/action-xcode-staple@1e2200b448c6ed4dd44b963ff17d3e340fc6b064 # v1
with:
product-path: "dist/refnx.dmg"
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: refnx-app-macos-${{ matrix.python-version }}
path: dist/*.dmg
###############################################################################
test_win:
runs-on: windows-latest
strategy:
fail-fast: true
max-parallel: 3
matrix:
python-version: ['3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
allow-prereleases: true
- run: pip install -r .requirements.txt
- run: mkdir -p dist
- name: Make wheel
run: |
python -m pip install --upgrade pip
python -m pip install wheel build delvewheel abi3audit
# python -m build --wheel -v
python -m build --wheel -Csetup-args="--vsenv"
delvewheel repair -w dist dist/*.whl
abi3audit --strict --report dist/refnx*.whl
- name: Install package and test with pytest
if: ${{ matrix.python-version == '3.12' }}
env:
PYOPENCL_CTX: 0
run: |
cd dist
python -m pip install --only-binary=refnx --no-index --find-links=. refnx
pytest --pyargs refnx
cd ..
- name: Check refnx gui starts
if: ${{ matrix.python-version == '3.12' }}
run: |
# check that refnx gui starts
pip install psutil
python tools/app/check_app_starts.py refnx
- name: Make frozen GUI executable
if: ${{ matrix.python-version == '3.12' }}
run: |
# make app in virtualenv
pip uninstall -y h5py
python -m venv app
app\Scripts\activate.bat
python -m pip install --upgrade --upgrade-strategy eager -r tools/app/requirements.txt
cd dist
python -m pip install --only-binary=refnx --no-index --find-links=. refnx
cd ..
# fix for multiprocessing on Py3.9 is not merged in PyInstaller
# if you are on Py3.7 you can just pip install pyinstaller
# pip install git+https://github.com/andyfaff/pyinstaller.git@gh4865
cd tools\app
pyinstaller motofit.spec
move dist\motofit.exe ..\..\dist\
cd ..\..
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: refnx-exe-win-${{ matrix.python-version }}
path: dist/
###############################################################################
build_doc:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: setup apt dependencies
run: |
sudo apt-get update
sudo apt-get install pandoc
- name: Build documentation
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install wheel
cd doc
python -m pip install -r requirements.txt
make html
###############################################################################
lint:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8 and black
run: |
python -m pip install ruff black
# stop the build if there are Python syntax errors or undefined names
# the ignores are taken care of by black
ruff check refnx
black --check refnx
- name: clang-format
run: |
sudo apt update
sudo apt install clang-format
cd src
clang-format --Werror -n *.cpp *.h *.c
cd pnr
clang-format --Werror -n *.cc *.h