-
Notifications
You must be signed in to change notification settings - Fork 4
201 lines (175 loc) · 7.9 KB
/
test-win-exe-w-embed-py.yaml
File metadata and controls
201 lines (175 loc) · 7.9 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
name: Build Streamlit Windows Installer (Multi-CAB, Embeddable Python)
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
build-win-installer:
runs-on: windows-2022
env:
PYTHON_VERSION: 3.10.0
APP_NAME: OpenMS-NuXLApp-Test
APP_UpgradeCode: 4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ----------------------------------------------------------------------
# Download embeddable Python
# ----------------------------------------------------------------------
- name: Download Python embeddable
shell: bash
run: |
mkdir python-${PYTHON_VERSION}
curl -LO https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip
unzip python-${PYTHON_VERSION}-embed-amd64.zip -d python-${PYTHON_VERSION}
rm python-${PYTHON_VERSION}-embed-amd64.zip
- name: Install pip into embeddable Python
shell: bash
run: |
curl -LO https://bootstrap.pypa.io/get-pip.py
./python-${PYTHON_VERSION}/python get-pip.py --no-warn-script-location
rm get-pip.py
- name: Enable site-packages (import site)
shell: bash
run: |
sed -i 's/#import site/import site/' python-${PYTHON_VERSION}/python310._pth
- name: Install Python requirements
run: |
.\python-${{ env.PYTHON_VERSION }}\python -m pip install -r requirements.txt --no-warn-script-location
# ----------------------------------------------------------------------
# Build portable application directory
# ----------------------------------------------------------------------
- name: Create launcher batch file
shell: bash
run: |
echo "start /min python-${PYTHON_VERSION}\\python -m streamlit run app.py local" > ${APP_NAME}.bat
- name: Assemble portable app folder
run: |
Remove-Item -Recurse -Force streamlit_exe -ErrorAction SilentlyContinue
mkdir streamlit_exe
mv python-${{ env.PYTHON_VERSION }} streamlit_exe
cp -r src streamlit_exe
cp -r content streamlit_exe
cp -r assets streamlit_exe
cp -r example-data streamlit_exe
cp -r .streamlit streamlit_exe
cp app.py streamlit_exe
cp settings.json streamlit_exe
cp ${{ env.APP_NAME }}.bat streamlit_exe
# Optional but strongly recommended: reduce file count
#- name: Remove Python caches and tests
# run: |
# Get-ChildItem streamlit_exe -Recurse -Directory -Filter "__pycache__" | Remove-Item -Recurse -Force
# Get-ChildItem streamlit_exe -Recurse -Directory -Match "test","tests" | Remove-Item -Recurse -Force
# ----------------------------------------------------------------------
# Install WiX Toolset 3.11
# ----------------------------------------------------------------------
- name: Install WiX
shell: bash
run: |
curl -LO https://github.com/wixtoolset/wix3/releases/download/wix3111rtm/wix311-binaries.zip
unzip wix311-binaries.zip -d wix
rm wix311-binaries.zip
# ----------------------------------------------------------------------
# Split harvesting (CRITICAL PART)
# ----------------------------------------------------------------------
- name: Harvest application files (no Python)
run: |
./wix/heat.exe dir streamlit_exe `
-gg -sfrag -sreg -srd `
-template component `
-cg AppFiles `
-dr AppSubFolder `
-x streamlit_exe/python-${{ env.PYTHON_VERSION }} `
-out app_files.wxs
- name: Harvest Python runtime (no site-packages)
run: |
./wix/heat.exe dir streamlit_exe/python-${{ env.PYTHON_VERSION }} `
-gg -sfrag -sreg -srd `
-template component `
-cg PythonRuntime `
-dr AppSubFolder `
-x streamlit_exe/python-${{ env.PYTHON_VERSION }}/Lib/site-packages `
-out python_runtime.wxs
- name: Harvest Python site-packages
run: |
./wix/heat.exe dir streamlit_exe/python-${{ env.PYTHON_VERSION }}/Lib/site-packages `
-gg -sfrag -sreg -srd `
-template component `
-cg PythonPackages `
-dr AppSubFolder `
-out python_packages.wxs
# ----------------------------------------------------------------------
# Assign DiskId to avoid CAB overflow
# ----------------------------------------------------------------------
- name: Assign DiskId per harvest
shell: bash
run: |
sed -i 's/<File /<File DiskId="1" /' app_files.wxs
sed -i 's/<File /<File DiskId="2" /' python_runtime.wxs
sed -i 's/<File /<File DiskId="3" /' python_packages.wxs
# ----------------------------------------------------------------------
# Prepare SourceDir
# ----------------------------------------------------------------------
- name: Prepare SourceDir
run: |
mkdir SourceDir
mv streamlit_exe/* SourceDir
cp assets/openms_license.rtf SourceDir
cp assets/openms.ico SourceDir
# ----------------------------------------------------------------------
# Main WiX product file
# ----------------------------------------------------------------------
- name: Generate main WiX file
shell: bash
run: |
cat <<EOF > installer.wxs
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="${APP_NAME}" Language="1033"
Version="1.0.0.0"
Manufacturer="OpenMS Developer Team"
UpgradeCode="${APP_UpgradeCode}">
<Package InstallerVersion="300" Compressed="yes" Platform="x64"/>
<Media Id="1" Cabinet="app.cab" EmbedCab="yes"/>
<Media Id="2" Cabinet="python.cab" EmbedCab="yes"/>
<Media Id="3" Cabinet="packages.cab" EmbedCab="yes"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="${APP_NAME}">
<Directory Id="AppSubFolder" Name="${APP_NAME}"/>
</Directory>
</Directory>
<Directory Id="DesktopFolder"/>
</Directory>
<Feature Id="MainFeature" Level="1">
<ComponentGroupRef Id="AppFiles"/>
<ComponentGroupRef Id="PythonRuntime"/>
<ComponentGroupRef Id="PythonPackages"/>
</Feature>
<Icon Id="AppIcon" SourceFile="SourceDir/openms.ico"/>
<WixVariable Id="WixUILicenseRtf" Value="SourceDir/openms_license.rtf"/>
<UI>
<UIRef Id="WixUI_InstallDir"/>
<UIRef Id="WixUI_ErrorProgressText"/>
</UI>
</Product>
</Wix>
EOF
# ----------------------------------------------------------------------
# Build MSI
# ----------------------------------------------------------------------
- name: Compile WiX sources
run: |
./wix/candle.exe installer.wxs app_files.wxs python_runtime.wxs python_packages.wxs
- name: Link MSI
run: |
./wix/light.exe -ext WixUIExtension -o ${APP_NAME}.msi installer.wixobj app_files.wixobj python_runtime.wixobj python_packages.wixobj
# ----------------------------------------------------------------------
# Upload artifact
# ----------------------------------------------------------------------
- name: Upload MSI
uses: actions/upload-artifact@v4
with:
name: OpenMS-Windows-MSI
path: ${{ env.APP_NAME }}.msi