forked from OpenMS/OpenMS
-
Notifications
You must be signed in to change notification settings - Fork 0
789 lines (662 loc) · 30.5 KB
/
pyopenms-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
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
# This builds python wheels on manylinux, macOS and Windows and uploads them
# to public pypi for release and for nightlies also to pypi.cs.uni-tuebingen.de
name: pyopenms-wheels-and-packages
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
inputs:
upload-to-pypi:
type: boolean
description: actually upload the release package to pypi.org
default: false
push:
tags:
- 'Release*'
branches: [ nightly, py_nightly_test ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
path: OpenMS
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.25.x'
- name: Reduce PATH # This fixes a bug described in https://github.com/facebook/watchman/commit/59bcfbf91d2a24ab580b8a78e384f133cc202383
run: echo "DISTUTILS_USE_SDK=1"
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.*'
host: 'windows' # default: win64_msvc2017_64
target: 'desktop'
install-deps: 'true'
archives: 'qtsvg qtbase'
cache: 'false'
- name: Install Miniconda
shell: bash # uses git bash on windows
run: |
MINICONDA_FILENAME=Miniconda3-latest-Windows-x86_64.exe
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
./Miniconda3-latest-Windows-x86_64.exe //InstallationType=JustMe //RegisterPython=0 //S //D=$HOME/miniconda3
- name: Download contrib build from archive (Windows)
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd OpenMS/contrib
# Download the file using the URL fetched from GitHub
gh release download -R OpenMS/contrib --pattern 'contrib_build-Windows.tar.gz'
# Extract the archive
7z x -so contrib_build-Windows.tar.gz | 7z x -si -ttar
rm contrib_build-Windows.tar.gz
ls -la
# https://github.com/marketplace/actions/visual-studio-shell
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
arch: x64
- name: Setup conda paths
shell: bash
run: |
echo "$HOME/miniconda3/bin" >> $GITHUB_PATH
echo "$HOME/miniconda3/Scripts" >> $GITHUB_PATH
- name: Build on Windows
shell: bash
run: |
PYTHON_VERSIONS=$(cat OpenMS/.github/workflows/python_versions.json)
CMAKE_PREFIX_PATH="$(echo $Qt6_Dir)/lib/cmake;${Qt6_Dir}"
#mkdir bld
#pushd bld
# TODO: set generator via variable, then we can share this step
# cmake --version
# cmake -G "Visual Studio 17 2022" -A x64 -DOPENMS_CONTRIB_LIBS="$GITHUB_WORKSPACE/OpenMS/contrib" -DCMAKE_PREFIX_PATH="$(echo $Qt6_Dir)/lib/cmake;${Qt6_Dir}" ../OpenMS
# Note: multiple --targets only supported by CMake 3.15+
# cmake --build . --config Release --target OpenMS
#ctest --progress --output-on-failure -VV -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake
export CXXFLAGS="-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR $CXXFLAGS"
mkdir pyopenms_whls
# The growing PATH leads to a failure in the last iteration of the pyopenms build process.
# We will store the PATH variable in the beginning and reset it with every iteration.
RESET_PATH=$PATH
for py in $(echo "${PYTHON_VERSIONS}" | jq -r '.[]'); do
# clean previous pyopenms libs
find . -name "_pyopenms*.pyd" -exec rm -rf {} \;
# reset the path
PATH=$RESET_PATH
# create and activate conda environment
py=$(echo "$py" | tr -d " \r\n")
pynodot=$(echo "$py" | tr -d ".")
conda create -n pyoms-bld-"${pynodot}" python="${py}"
source activate pyoms-bld-"${pynodot}"
# set current python executable
CURRENT_PYTHON_EXECUTABLE=$(which python)
${CURRENT_PYTHON_EXECUTABLE} -m pip install --upgrade pip
# pip install all the stuff
${CURRENT_PYTHON_EXECUTABLE} -m pip install -r $GITHUB_WORKSPACE/OpenMS/src/pyOpenMS/requirements_bld.txt
# Get the Python root directory
export Python_ROOT_DIR=$(conda info --json | jq -r '.sys.prefix')
echo "Python root directory: $Python_ROOT_DIR"
export BUILD_NAME="pyopenms-wheels-${{ runner.arch }}-class-pyopenms-$py-${{ github.run_number }}" #TODO make this more expressive
# build pyopenms distribution
ctest --output-on-failure -VV -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake --config Release
echo "Current dir is `pwd`"
echo "wheels are in `find . | grep whl`"
echo "current ls is `ls -la`"
# copy to directory
cp OpenMS/bld/pyOpenMS/dist/*.whl pyopenms_whls/
# clean up
#conda deactivate
#conda remove --name "pyoms-bld-${pynodot}" --all
done
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CMAKE_GENERATOR: "Visual Studio 17 2022"
CMAKE_GENERATOR_PLATFORM: "x64"
OPENMS_CONTRIB_LIBS: "${{ github.workspace }}/OpenMS/contrib"
#CMAKE_PREFIX_PATH: "$(echo $Qt6_Dir)/lib/cmake;${Qt6_Dir}" #TODO move this to env
BUILD_TYPE: "Release"
CI_PROVIDER: "GitHub-Actions"
CMAKE_CCACHE_EXE: "ccache"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 12
CCACHE_MAXSIZE: 400M
PYOPENMS: "ON"
PY_NUM_THREADS: ${{ steps.cpu-cores.outputs.count }}
ENABLE_TUTORIALS: "OFF"
ENABLE_DOCS: "OFF"
ENABLE_PIPELINE_TESTING: "OFF"
ENABLE_STYLE_TESTING: "OFF"
ENABLE_TOPP_TESTING: "OFF"
ENABLE_CLASS_TESTING: "OFF"
- name: Run Unit Tests
shell: bash
run: |
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/citest.cmake -C Release
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CI_PROVIDER: "GitHub-Actions"
BUILD_NAME: "${{ runner.arch }}-class-pyopenms-${{ github.run_number }}"
BUILD_TYPE: "Release"
# The rest of the vars should be saved in the CMakeCache
- uses: actions/upload-artifact@v4
name: Upload artifacts
with:
name: ${{ runner.os }}-${{ runner.arch }}-wheels
path: pyopenms_whls
build-macos-arm:
runs-on: macos-latest
env:
SYSTEM_VERSION_COMPAT: 0 # workaround for mac see https://github.com/actions/setup-python/issues/469 for details.
steps:
- uses: actions/checkout@v4
with:
path: OpenMS
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.25.x'
- name: Install Miniconda
shell: bash
run: |
MINICONDA_FILENAME=Miniconda3-latest-MacOSX-arm64.sh
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3
- name: Setup conda paths
shell: bash
run: |
echo "$HOME/miniconda3/bin" >> $GITHUB_PATH
echo "$HOME/miniconda3/Scripts" >> $GITHUB_PATH
- name: Force update all brew python
run: |
brew update
# GHA messes with links https://github.com/actions/setup-python/issues/577 so we just force replace their installs' with brew's
for pkg in $(brew list --formula | grep -E '^python(@[0-9]+\.[0-9]+)?$'); do
brew upgrade --force --overwrite "$pkg"
done
brew cleanup
- name: Install build tools
run: brew install --force --overwrite autoconf automake libtool
- name: Install contrib packages from brew
run: |
## Needed for Qt. Install before to overwrite the default softlinks on the GH runners
brew install --force --overwrite --quiet ccache autoconf automake libtool ninja && brew link --overwrite ccache
brew install --force --overwrite libsvm xerces-c boost eigen sqlite coinutils cbc cgl clp qt@6 libomp
brew link --force libomp
echo "cmake_prefix=$(brew --prefix qt@6)/lib/cmake;$(brew --prefix libomp)" >> $GITHUB_OUTPUT
echo "Qt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6" >> $GITHUB_ENV
if [[ "${{ steps.set-vars.outputs.pkg_type }}" != "none" ]]; then
brew install --force --overwrite --quiet doxygen ghostscript graphviz
fi
- name: Build on macos arm
run: |
PYTHON_VERSIONS=$(cat OpenMS/.github/workflows/python_versions.json)
# export CC=clang
# export CXX=clang++
# export MACOSX_DEPLOYMENT_TARGET=12
# Unfortunately, on macOS due to the inofficial way of enabling OpenMP on AppleClang, passing the following
# options to setup.py extra_compile_args does not work. See also https://gist.github.com/andyfaff/084005bee32aee83d6b59e843278ab3e
export CFLAGS="-Xpreprocessor -fopenmp $CFLAGS"
export CXXFLAGS="-Xpreprocessor -fopenmp $CXXFLAGS"
# mkdir bld
# pushd bld
# Use -DCMAKE_FIND_DEBUG_MODE=ON for debug
# export OpenMP_ROOT="$(brew --prefix libomp)"
export CMAKE_PREFIX_PATH="$(brew --prefix libomp);$(echo $Qt6_DIR)/lib/cmake;${Qt6_DIR}"
#ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake
#cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_PREFIX_PATH="$(brew --prefix libomp);$(echo $Qt6_Dir)/lib/cmake;${Qt6_Dir}" -DCMAKE_OSX_DEPLOYMENT_TARGET=12 -DBOOST_USE_STATIC=OFF ../OpenMS
#make -j${{ steps.cpu-cores.outputs.count }} OpenMS
mkdir pyopenms_whls
for py in $(echo "${PYTHON_VERSIONS}" | jq -r '.[]'); do
# clean previous pyopenms libs
# do at the top of the python version loop so that we leave the final libraries for testing
find . -name "_pyopenms*.so" -exec rm -rf {} \;
py=$(echo "$py" | tr -d " \n")
pynodot=$(echo "$py" | tr -d ".")
conda create -n pyoms-bld-"${pynodot}" python="${py}"
source activate pyoms-bld-"${pynodot}"
# set current python executable
CURRENT_PYTHON_EXECUTABLE=$(which python)
${CURRENT_PYTHON_EXECUTABLE} -m pip install --upgrade pip
# pip install all the stuff
${CURRENT_PYTHON_EXECUTABLE} -m pip install -r $GITHUB_WORKSPACE/OpenMS/src/pyOpenMS/requirements_bld.txt
# Get the Python root directory
export Python_ROOT_DIR=$(conda info --json | jq -r '.sys.prefix')
echo "Python root directory: $Python_ROOT_DIR"
export BUILD_NAME="pyopenms-wheels-${{ runner.arch }}-class-pyopenms-$py-${{ github.run_number }}" #TODO make this more expressive
# build pyopenms distribution (macOS)
ctest --output-on-failure -VV -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake
# TODO REMOVE DEBUGGING
echo "Current dir is `pwd`"
echo "wheels are in `find . | grep whl`"
echo "current ls is `ls -la`"
# cmake -DPYTHON_EXECUTABLE:FILEPATH=$CURRENT_PYTHON_EXECUTABLE -DPYOPENMS=ON -DPY_NUM_THREADS=${{ steps.cpu-cores.outputs.count }} .
# make -j${{ steps.cpu-cores.outputs.count }} pyopenms
# copy to directory
cp OpenMS/bld/pyOpenMS/dist/*.whl pyopenms_whls/
# clean up
# conda deactivate
# conda remove --name pyoms-bld-"${pynodot}" --all
done
env:
CC: "clang"
CXX: "clang++"
BOOST_USE_STATIC: "OFF" #TODO check if necessary?
MACOSX_DEPLOYMENT_TARGET: "12"
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CMAKE_GENERATOR: "Ninja"
OPENMS_CONTRIB_LIBS: "$GITHUB_WORKSPACE/OpenMS/contrib"
BUILD_TYPE: "Release"
BUILD_NAME: "${{ runner.arch }}-class-pyopenms-${{ github.run_number }}" #TODO make this more expressive
BUILD_FLAGS: "-j${{ steps.cpu-cores.outputs.count }}"
CI_PROVIDER: "GitHub-Actions"
CMAKE_CCACHE_EXE: "ccache"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 12
CCACHE_MAXSIZE: 400M
# MT_ENABLE_OPENMP: "ON"
PYOPENMS: "ON"
PY_NUM_THREADS: ${{ steps.cpu-cores.outputs.count }}
ENABLE_TUTORIALS: "OFF"
ENABLE_DOCS: "OFF"
ENABLE_PIPELINE_TESTING: "OFF"
ENABLE_STYLE_TESTING: "OFF"
ENABLE_TOPP_TESTING: "OFF"
ENABLE_CLASS_TESTING: "OFF"
- name: Run Unit Tests
shell: bash
run: |
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/citest.cmake
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CI_PROVIDER: "GitHub-Actions"
BUILD_NAME: "${{ runner.arch }}-class-pyopenms-${{ github.run_number }}"
# The rest of the vars should be saved in the CMakeCache
- uses: actions/upload-artifact@v4
name: Upload artifacts
if: always()
with:
name: ${{ runner.os }}-buildfiles
path: |
CMakeCache.txt
pyOpenMS/env.py
- uses: actions/upload-artifact@v4
name: Upload wheels
with:
name: ${{ runner.os }}-${{ runner.arch }}-wheels
path: pyopenms_whls
build-macos:
runs-on: macos-13
env:
SYSTEM_VERSION_COMPAT: 0 # workaround for mac see https://github.com/actions/setup-python/issues/469 for details.
steps:
- uses: actions/checkout@v4
with:
path: OpenMS
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.25.x'
- name: Install Miniconda
shell: bash
run: |
MINICONDA_FILENAME=Miniconda3-latest-MacOSX-x86_64.sh
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3
- name: Setup conda paths
shell: bash
run: |
echo "$HOME/miniconda3/bin" >> $GITHUB_PATH
echo "$HOME/miniconda3/Scripts" >> $GITHUB_PATH
- name: Force update all brew python
run: |
brew update
# GHA messes with links https://github.com/actions/setup-python/issues/577 so we just force replace their installs' with brew's
for pkg in $(brew list --formula | grep -E '^python(@[0-9]+\.[0-9]+)?$'); do
brew upgrade --force --overwrite "$pkg"
done
brew cleanup
- name: Install build tools
run: brew install --force --overwrite autoconf automake libtool
- name: Install contrib packages from brew
run: |
## Update the package lists for Brew
## Needed for Qt. Install before to overwrite the default softlinks on the GH runners
brew install --force --overwrite --quiet ccache autoconf automake libtool ninja && brew link --overwrite ccache
brew install --force --overwrite libsvm xerces-c boost eigen sqlite coinutils cbc cgl clp qt@6 libomp
echo "cmake_prefix=$(brew --prefix qt@6)/lib/cmake;$(brew --prefix qt@6);$(brew --prefix libomp)" >> $GITHUB_OUTPUT
echo "Qt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6" >> $GITHUB_ENV
if [[ "${{ steps.set-vars.outputs.pkg_type }}" != "none" ]]; then
brew install --force --overwrite --quiet doxygen ghostscript graphviz
fi
- name: Build on macos intel
run: |
PYTHON_VERSIONS=$(cat OpenMS/.github/workflows/python_versions.json)
export CC=clang
export CXX=clang++
export MACOSX_DEPLOYMENT_TARGET=12
# Unfortunately, on macOS due to the inofficial way of enabling OpenMP on AppleClang, passing the following
# options to setup.py extra_compile_args does not work. See also https://gist.github.com/andyfaff/084005bee32aee83d6b59e843278ab3e
export CFLAGS="-Xpreprocessor -fopenmp $CFLAGS"
export CXXFLAGS="-Xpreprocessor -fopenmp $CXXFLAGS"
# export OpenMP_ROOT="$(brew --prefix libomp)"
export CMAKE_PREFIX_PATH="$(brew --prefix libomp);$(echo $Qt6_Dir)/lib/cmake;${Qt6_Dir}"
#mkdir bld
#pushd bld
# Use -DCMAKE_FIND_DEBUG_MODE=ON for debug
#cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_PREFIX_PATH="$(brew --prefix libomp);$(echo $Qt6_Dir)/lib/cmake;${Qt6_Dir}" -DCMAKE_OSX_DEPLOYMENT_TARGET=12 -DBOOST_USE_STATIC=OFF ../OpenMS
#make -j${{ steps.cpu-cores.outputs.count }} OpenMS
mkdir pyopenms_whls
for py in $(echo "${PYTHON_VERSIONS}" | jq -r '.[]'); do
# clean previous pyopenms libs
# do at the top of the python version loop so that we leave the final libraries for testing
find . -name "_pyopenms*.so" -exec rm -rf {} \;
py=$(echo "$py" | tr -d " \n")
pynodot=$(echo "$py" | tr -d ".")
conda create -n pyoms-bld-"${pynodot}" python="${py}"
source activate pyoms-bld-"${pynodot}"
# set current python executable
CURRENT_PYTHON_EXECUTABLE=$(which python)
${CURRENT_PYTHON_EXECUTABLE} -m pip install --upgrade pip
# pip install all the stuff
${CURRENT_PYTHON_EXECUTABLE} -m pip install -r $GITHUB_WORKSPACE/OpenMS/src/pyOpenMS/requirements_bld.txt
# Get the Python root directory
export Python_ROOT_DIR=$(conda info --json | jq -r '.sys.prefix')
echo "Python root directory: $Python_ROOT_DIR"
export BUILD_NAME="pyopenms-wheels-${{ runner.arch }}-class-pyopenms-$py-${{ github.run_number }}" #TODO make this more expressive
# build pyopenms distribution (macOS)
ctest --output-on-failure -VV -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake
# TODO REMOVE DEBUGGING
echo "Current dir is `pwd`"
echo "wheels are in `find . | grep whl`"
echo "current ls is `ls -la`"
# cmake -DPYTHON_EXECUTABLE:FILEPATH=$CURRENT_PYTHON_EXECUTABLE -DPYOPENMS=ON -DPY_NUM_THREADS=${{ steps.cpu-cores.outputs.count }} .
# make -j${{ steps.cpu-cores.outputs.count }} pyopenms
# copy to directory
cp OpenMS/bld/pyOpenMS/dist/*.whl pyopenms_whls/
# clean up
#conda deactivate
#conda remove --name pyoms-bld-"${pynodot}" --all
# clean previous pyopenms libs
#find . -name "_pyopenms*.so" -exec rm -rf {} \;
done
env:
CC: "clang"
CXX: "clang++"
MACOSX_DEPLOYMENT_TARGET: "12"
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CMAKE_GENERATOR: "Ninja"
OPENMS_CONTRIB_LIBS: "$GITHUB_WORKSPACE/OpenMS/contrib"
BOOST_USE_STATIC: "OFF"
BUILD_TYPE: "Release"
BUILD_NAME: "${{ runner.arch }}-class-pyopenms-${{ github.run_number }}" #TODO make this more expressive
BUILD_FLAGS: "-j${{ steps.cpu-cores.outputs.count }}"
CI_PROVIDER: "GitHub-Actions"
CMAKE_CCACHE_EXE: "ccache"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 12
CCACHE_MAXSIZE: 400M
#MT_ENABLE_OPENMP: "ON"
PYOPENMS: "ON"
PY_NUM_THREADS: ${{ steps.cpu-cores.outputs.count }}
ENABLE_TUTORIALS: "OFF"
ENABLE_DOCS: "OFF"
ENABLE_STYLE_TESTING: "OFF"
ENABLE_PIPELINE_TESTING: "OFF"
ENABLE_TOPP_TESTING: "OFF"
ENABLE_CLASS_TESTING: "OFF"
- name: Test
shell: bash
run: |
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/citest.cmake
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CI_PROVIDER: "GitHub-Actions"
BUILD_NAME: "${{ runner.arch }}-class-pyopenms-${{ github.run_number }}"
# The rest of the vars should be saved in the CMakeCache
- uses: actions/upload-artifact@v4
name: Upload wheels
with:
name: ${{ runner.os }}-${{ runner.arch }}-wheels
path: pyopenms_whls
build-lnx:
runs-on: [ubuntu-latest]
container: ghcr.io/openms/contrib_manylinux_2_34:latest
steps:
# Cancels older builds if still running
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Disable warning for this line
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/develop'" # noqa
- uses: actions/checkout@v4
name: Checkout sources
with:
path: OpenMS
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.25.x'
- name: Build on manylinux for broad compatibility
shell: bash
run: |
PYTHON_VERSIONS=$(cat OpenMS/.github/workflows/python_versions.json)
yum install -y jq
yum install -y ninja-build # Install Ninja for build files
cmake --version
mkdir -p $GITHUB_WORKSPACE/data/wheelhouse/
mkdir -p $GITHUB_WORKSPACE/data/wheelhouse/before_fix/
LD_OLD_LIBRARY_PATH=$LD_LIBRARY_PATH
# compile and configure OpenMS
for py in $(echo "${PYTHON_VERSIONS}" | jq -r '.[]'); do
# Check if there is already and existing build,
# if so: clean previous pyopenms libs,
# do at the top of the python version loop so that we leave the final libraries for testing
if [ -d "OpenMS/bld/pyOpenMS/pyopenms" ]; then
rm OpenMS/bld/pyOpenMS/pyopenms/_pyopenms*.so
fi
py=$(echo "$py" | tr -d " \n")
pynodot=$(echo "$py" | tr -d ".")
PYBIN=$(echo /opt/python/cp*${pynodot})
# Create a venv for this python version
"$PYBIN/bin/python" -m venv $pynodot
source $pynodot/bin/activate
"$PYBIN/bin/pip" install --upgrade pip
# pip install all the stuff
"$PYBIN/bin/pip" install -r $GITHUB_WORKSPACE/OpenMS/src/pyOpenMS/requirements_bld.txt
# configure (don't copy deps since we use auditwheel)
export Python_ROOT_DIR=$PYBIN
export BUILD_NAME="pyopenms-wheels-${{ runner.arch }}-class-pyopenms-$py-${{ github.run_number }}" #TODO make this more expressive
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake
# ensure auditwheel can find the libraries
export LD_LIBRARY_PATH=$LD_OLD_LIBRARY_PATH:`pwd`/OpenMS/bld/lib
# strip the libraries before repairing
strip --strip-all OpenMS/bld/lib/libOpenMS.so
strip --strip-all OpenMS/bld/lib/libOpenSwathAlgo.so
pushd OpenMS/bld/pyOpenMS
# Bundle stripped plus external shared libraries into the wheels
for whl in dist/pyopenms*.whl; do
auditwheel repair "$whl" -w wheelhouse/
done
mv wheelhouse/* $GITHUB_WORKSPACE/data/wheelhouse/
popd
export LD_LIBRARY_PATH=$LD_OLD_LIBRARY_PATH
# deactivate the venv
deactivate
done
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CMAKE_GENERATOR: "Ninja"
OPENMS_CONTRIB_LIBS: "/contrib-build/"
BUILD_TYPE: "Release"
BUILD_FLAGS: "-j${{ steps.cpu-cores.outputs.count }}"
NO_DEPENDENCIES: "ON"
Python_FIND_STRATEGY: "LOCATION"
PYOPENMS: "ON"
PY_NUM_THREADS: ${{ steps.cpu-cores.outputs.count }}
CI_PROVIDER: "GitHub-Actions"
CMAKE_CXX_COMPILER: "g++"
CMAKE_PREFIX_PATH: "/contrib-build/"
ENABLE_TUTORIALS: "OFF"
ENABLE_DOCS: "OFF"
ENABLE_STYLE_TESTING: "OFF"
ENABLE_PIPELINE_TESTING: "OFF"
ENABLE_TOPP_TESTING: "OFF"
ENABLE_CLASS_TESTING: "OFF"
- name: Test
shell: bash
run: |
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/citest.cmake
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CI_PROVIDER: "GitHub-Actions"
BUILD_NAME: "${{ runner.arch }}-class-pyopenms-${{ github.run_number }}"
# The rest of the vars should be saved in the CMakeCache
- uses: actions/upload-artifact@v4
name: Upload artifacts
with:
name: ${{ runner.os }}-${{ runner.arch }}-wheels
path: data/wheelhouse/
# Tests the build workflows
test:
needs: [build-win, build-macos, build-lnx, build-macos-arm]
runs-on: ${{ matrix.os }}
env:
SYSTEM_VERSION_COMPAT: 0 #courtesy of https://github.com/actions/setup-python/issues/469 in lieu of an actual solution.
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
name: Checkout sources
with:
path: OpenMS
- name: Install Miniconda
shell: bash
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
MINICONDA_FILENAME=Miniconda3-latest-Linux-x86_64.sh
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3
elif [[ "${{ runner.os }}" == "macOS" && "${{ runner.arch }}" == "X64" ]]; then
MINICONDA_FILENAME=Miniconda3-latest-MacOSX-x86_64.sh
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3
elif [[ "${{ runner.os }}" == "macOS" && "${{ runner.arch }}" == "ARM64" ]]; then
MINICONDA_FILENAME=Miniconda3-latest-MacOSX-arm64.sh
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3
elif [[ "${{ runner.os }}" == "Windows" ]]; then
MINICONDA_FILENAME=Miniconda3-latest-Windows-x86_64.exe
curl -o $MINICONDA_FILENAME "https://repo.anaconda.com/miniconda/$MINICONDA_FILENAME"
./Miniconda3-latest-Windows-x86_64.exe //InstallationType=JustMe //RegisterPython=0 //S
fi
- name: Setup conda paths
shell: bash
run: |
echo "$HOME/miniconda3/bin" >> $GITHUB_PATH
echo "$HOME/miniconda3/Scripts" >> $GITHUB_PATH
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ runner.os }}-${{ runner.arch }}-wheels
- name: Test
shell: bash
run: |
PYTHON_VERSIONS=$(cat OpenMS/.github/workflows/python_versions.json)
echo $PYTHON_VERSIONS
for py in $(echo "${PYTHON_VERSIONS}" | jq -r '.[]'); do
py=$(echo "$py" | tr -d " \r\n")
pynodot=$(echo "$py" | tr -d ".")
conda create -n pyoms-bld-$pynodot python=$py
source activate pyoms-bld-$pynodot
# Find .whl for current python version
CURRENT_VERSION=$(echo $py | sed "s/\.//g") # remove "." for find
echo "Testing python version $CURRENT_VERSION"
CURRENT_WHL=$(find $GITHUB_WORKSPACE -name "*cp$CURRENT_VERSION*.whl") # Probably $GITHUB_WORKSPACE
if [[ "$CURRENT_WHL" == '' ]]; then
continue
fi
echo "Found wheel $CURRENT_WHL : Testing.."
# pip install all the stuff
python -m pip install --upgrade pip
python -m pip install $CURRENT_WHL
# check if package was installed
python -c "import importlib.util; p_name = 'pyopenms'; package = importlib.util.find_spec(p_name); print(p_name + ' was sucessfully installed! Nice one!') if package is not None else print('Something seems to be wrong!')"
# run test
python -c "exec(\"import pyopenms\nprint(pyopenms.EmpiricalFormula(\'C6H12O6\').getMonoWeight())\")"
conda deactivate
# clean up
conda remove --name pyoms-bld-$pynodot --all
done
# Upload the wheels (the action only runs on ubuntu slaves)
publish:
needs: [test] # doesn't really NEED it but we want the tests to pass first
runs-on: ubuntu-latest
steps:
# haha github is just ridiculous.. not getting their actions to do basic stuff for years
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Linux-X64-wheels
path: /home/runner/work/OpenMS/OpenMS/Linux-X64-wheels
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Windows-X64-wheels
path: /home/runner/work/OpenMS/OpenMS/Windows-X64-wheels
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: macOS-X64-wheels
path: /home/runner/work/OpenMS/OpenMS/macOS-X64-wheels
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: macOS-ARM64-wheels
path: /home/runner/work/OpenMS/OpenMS/macOS-ARM64-wheels
- name: Merge all artifacts
run: |
mkdir wheels
cp -lr *-wheels/* wheels/
pwd
ls -la wheels/
- name: Publish package to nightly PyPI
# Upload the wheels to our pypi server for develop, nightly and release branches (unless it's explictly stated to upload it to pypi.org)
if: contains(github.ref, 'develop') || contains(github.ref, 'nightly') || (contains(github.ref, 'Release') && inputs.upload-to-pypi == 'false')
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://pypi.cs.uni-tuebingen.de/
user: openms
password: ${{ secrets.abiservices_pypi_pw }}
packages-dir: ${{ github.workspace }}/wheels
- name: Publish package to PyPI
if: contains(github.ref, 'Release') && inputs.upload-to-pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
repository-url: https://pypi.org/
password: ${{ secrets.pypi_api_token_release }}
packages-dir: ${{ github.workspace }}/wheels