-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathbuild-windows-executable-app-with-pyinstaller.yaml
More file actions
345 lines (299 loc) · 11.2 KB
/
build-windows-executable-app-with-pyinstaller.yaml
File metadata and controls
345 lines (299 loc) · 11.2 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
name: Build executable for Windows with pyinstaller
on:
workflow_dispatch:
env:
OPENMS_VERSION: 3.2.0
# Control whether to build pyOpenMS from source (true) or use pip (false). Default: false
BUILD_PYOPENMS: false
# Define needed TOPP tools here
TOPP_TOOLS: "FeatureFinderMetabo MetaboliteAdductDecharger SiriusExport"
jobs:
build-openms:
runs-on: windows-latest
env:
PYTHON_VERSION: 3.11.0
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: OpenMS/OpenMS
ref: release/${{ env.OPENMS_VERSION }}
path: 'OpenMS'
# Temporary fix - until seqan is back online or new OpenMS release (3.4)
- name: Get latest cibuild.cmake
working-directory: OpenMS
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git fetch origin develop
git checkout origin/develop -- tools/ci/cibuild.cmake
git checkout origin/develop -- tools/ci/citest.cmake
git checkout origin/develop -- tools/ci/cipackage.cmake
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '5.15.2' # 5.12.7 is broken https://bugreports.qt.io/browse/QTBUG-81715, > 5.15.2 is not available on official archives (https://github.com/miurahr/aqtinstall/issues/636)
host: 'windows' # default: win64_msvc2017_64
target: 'desktop'
install-deps: 'true'
cache: 'false'
aqtversion: '==3.1.*'
# 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 build tools
shell: bash
run: |
choco install ccache ninja cmake
## GH CLI "SHOULD BE" installed. Sometimes I had to manually install nonetheless. Super weird.
# https://github.com/actions/runner-images/blob/main/images/win/scripts/Installers/Install-GitHub-CLI.ps1
echo "C:/Program Files (x86)/GitHub CLI" >> $GITHUB_PATH
- name: Set up Python for pyOpenMS build
if: env.BUILD_PYOPENMS == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies for pyOpenMS build
if: env.BUILD_PYOPENMS == 'true'
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel nose 'cython<3.1' 'autowrap<0.23' numpy
- name: Extract branch/PR infos
shell: bash
run: |
cd OpenMS
RUN_NAME_LOCAL=$(echo ${GITHUB_REF#refs/heads/} | tr / -)
echo "RUN_NAME=${RUN_NAME_LOCAL}" >> $GITHUB_ENV
echo "BASE_REF=$(gh pr view --json baseRefName -q .baseRefName || echo ${RUN_NAME_LOCAL})" >> $GITHUB_ENV
id: extract_branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache contrib
id: cache-contrib-win
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/OpenMS/contrib
key: ${{ runner.os }}-contrib3
- name: Load contrib build
if: steps.cache-contrib-win.outputs.cache-hit != 'true'
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
- name: Setup ccache cache
uses: actions/cache@v3
with:
path: .ccache
key: ${{ runner.os }}-ccache-${{ env.RUN_NAME }}-${{ github.run_number }}
# Restoring: From current branch, otherwise from base branch, otherwise from any branch.
restore-keys: |
${{ runner.os }}-ccache-${{ env.RUN_NAME }}
${{ runner.os }}-ccache-${{ env.BASE_REF }}
${{ runner.os }}-ccache-
- name: Add THIRDPARTY
shell: bash
run: |
# initialize THIRDPARTY
cd OpenMS
git submodule update --init THIRDPARTY
cd ..
# add third-party binaries to PATH
# use flat THIRDPARTY structure
mkdir -p _thirdparty
cp -R OpenMS/THIRDPARTY/Windows/64bit/* _thirdparty/
cp -R OpenMS/THIRDPARTY/All/* _thirdparty/
# add third-party binaries to PATH
for thirdpartytool in ${{ github.workspace }}/_thirdparty/*
do
echo $thirdpartytool >> $GITHUB_PATH
done
- name: Build Windows
shell: bash
run: |
mkdir $GITHUB_WORKSPACE/OpenMS/bld/
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake
env:
#OS_PREFIX_PATH: "${{ env.Qt5_DIR }}/lib/cmake;${{ env.Qt5_DIR }}"
CONTRIB_BUILD_DIRECTORY: "${{ github.workspace }}/OpenMS/contrib"
CI_PROVIDER: "GitHub-Actions"
CMAKE_GENERATOR: "Ninja"
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
BUILD_NAME: "${{ env.RUN_NAME }}-Win64-class-topp-${{ github.run_number }}"
ENABLE_STYLE_TESTING: "OFF"
ENABLE_TOPP_TESTING: "ON"
ENABLE_CLASS_TESTING: "ON"
WITH_GUI: "ON"
ADDRESS_SANITIZER: "Off"
BUILD_TYPE: "Release"
OPENMP: "Off"
USE_STATIC_BOOST: "On"
PYOPENMS: "${{ env.BUILD_PYOPENMS == 'true' && 'ON' || 'OFF' }}"
# BUILD_FLAGS: "-p:CL_MPCount=2" # For VS Generator and MSBuild
BUILD_FLAGS: "-j2" # Ninja will otherwise use all cores (doesn't go well in GHA)
CMAKE_CCACHE_EXE: "ccache"
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 12
CCACHE_MAXSIZE: 400M
- name: Build pyOpenMS
if: env.BUILD_PYOPENMS == 'true'
shell: bash
run: |
cd $GITHUB_WORKSPACE/OpenMS/bld/
ninja pyopenms
- name: Package pyOpenMS wheel
if: env.BUILD_PYOPENMS == 'true'
shell: bash
run: |
cd $GITHUB_WORKSPACE/OpenMS/bld/pyOpenMS
python -m pip install wheel
python setup.py bdist_wheel
- name: Upload pyOpenMS wheel as artifact
if: env.BUILD_PYOPENMS == 'true'
uses: actions/upload-artifact@v4
with:
name: pyopenms-wheel
path: ${{ github.workspace }}/OpenMS/bld/pyOpenMS/dist/*.whl
- name: Package
shell: bash
run: |
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cipackage.cmake
env:
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
PACKAGE_TYPE: zip
SEARCH_ENGINES_DIRECTORY: "${{ github.workspace }}/_thirdparty"
CI_PROVIDER: "GitHub-Actions"
CPACK_PACKAGE_FILE_NAME: "openms-package"
- name: Test Windows
shell: bash
run: $LAUNCHER ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/citest.cmake
env:
LAUNCHER: ""
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS"
CI_PROVIDER: "GitHub-Actions"
BUILD_NAME: "${{ env.RUN_NAME }}-Win64-class-topp-${{ github.run_number }}"
- name: Upload package as artifact
uses: actions/upload-artifact@v4
with:
name: openms-package
path: ${{ github.workspace }}/OpenMS/bld/*.zip
build-executable:
runs-on: windows-latest
needs: build-openms
env:
PYTHON_VERSION: 3.11.0
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download package as artifact
uses: actions/download-artifact@v4
with:
name: openms-package
path: openms-package
- name: Extract bin and share from package
run: |
cd openms-package
unzip "*.zip" -d .
cp -r openms-package/bin ../openms-bin
cp -r openms-package/share ../share
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Download pyOpenMS wheel (if built from source)
if: env.BUILD_PYOPENMS == 'true'
uses: actions/download-artifact@v4
with:
name: pyopenms-wheel
path: pyopenms-wheel
- name: Setup virtual environment
shell: cmd
run: |
python -m venv myenv
call myenv\Scripts\activate.bat
if "${{ env.BUILD_PYOPENMS }}" == "true" (
pip install pyopenms-wheel/*.whl
findstr /v /r /c:"^pyopenms" requirements.txt > requirements_filtered.txt
pip install -r requirements_filtered.txt
) else (
pip install -r requirements.txt
)
pip install pyinstaller
- name: Write function to cli.py
shell: bash
run: |
head -n -2 D:/a/streamlit-template/streamlit-template/myenv/Lib/site-packages/streamlit/web/cli.py > temp_cli.py
cat << EOF >> temp_cli.py
def _main_run_clExplicit(file, command_line, args=[], flag_options=[]):
main._is_running_with_streamlit = True
bootstrap.run(file, command_line, args, flag_options)
if __name__ == "__main__":
main()
EOF
mv temp_cli.py D:/a/streamlit-template/streamlit-template/myenv/Lib/site-packages/streamlit/web/cli.py
- name: Compile app with pyinstaller
shell: cmd
run: |
call myenv\Scripts\activate.bat
pyinstaller --onefile --additional-hooks-dir ./hooks run_app.py --clean
- name: Set to offline deployment
run: |
$content = Get-Content -Raw settings.json | ConvertFrom-Json
$content.online_deployment = $false
$content | ConvertTo-Json -Depth 100 | Set-Content settings.json
- name: Copy everything to dist directory
run: |
mkdir streamlit_exe
mv python-${{ env.PYTHON_VERSION }} streamlit_exe
mv run_app.bat streamlit_exe
cp -r src streamlit_exe
cp -r utils streamlit_exe
cp -r content streamlit_exe
cp -r docs streamlit_exe
cp -r assets streamlit_exe
cp -r example-data streamlit_exe
cp openms-bin/*.dll streamlit_exe
cp -r .streamlit streamlit_exe
cp -r share streamlit_exe/share
cp app.py streamlit_exe
cp settings.json streamlit_exe
cp default-parameters.json streamlit_exe
$files = $env:TOPP_TOOLS -split ' '
foreach ($file in $files) {
Copy-Item "openms-bin/${file}.exe" -Destination "streamlit_exe/${file}.exe"
}
- name: Modify .spec file
shell: bash
run: |
cp run_app_temp.spec run_app.spec
- name: Make executable
shell: cmd
run: |
call myenv\Scripts\activate.bat
pyinstaller run_app.spec --clean
- name: Delete OpenMS package artifact
uses: geekyeggo/delete-artifact@v5
with:
name: openms-package
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: OpenMS-App
path: dist
- name: Upload Artifact as Release Asset
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: OpenMS-App.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}