Skip to content

Commit 965ff2f

Browse files
authored
Create test-win-exe-w-embed-py.yaml
1 parent a7df0d1 commit 965ff2f

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: Test streamlit executable for Windows with embeddable python
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
workflow_dispatch:
6+
7+
jobs:
8+
build-win-executable-with-embeddable-python:
9+
runs-on: windows-2022
10+
11+
env:
12+
PYTHON_VERSION: 3.10.0
13+
APP_UpgradeCode: 4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb
14+
APP_NAME: OpenMS-NuXLApp-Test
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Download python embeddable version
21+
run: |
22+
mkdir python-${{ env.PYTHON_VERSION }}
23+
curl -O https://www.python.org/ftp/python/${{ env.PYTHON_VERSION }}/python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
24+
unzip python-${{ env.PYTHON_VERSION }}-embed-amd64.zip -d python-${{ env.PYTHON_VERSION }}
25+
rm python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
26+
27+
- name: Install pip
28+
run: |
29+
curl -O https://bootstrap.pypa.io/get-pip.py
30+
./python-${{ env.PYTHON_VERSION }}/python get-pip.py --no-warn-script-location
31+
rm get-pip.py
32+
33+
- name: Uncomment 'import site' in python310._pth file
34+
run: |
35+
sed -i 's/#import site/import site/' python-${{ env.PYTHON_VERSION }}/python310._pth
36+
37+
- name: Print content of python310._pth file
38+
run: |
39+
cat python-${{ env.PYTHON_VERSION }}/python310._pth
40+
41+
- name: Install Required Packages
42+
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install -r requirements.txt --no-warn-script-location
43+
44+
- name: Create .bat file
45+
run: |
46+
echo " start /min .\python-${{ env.PYTHON_VERSION }}\python -m streamlit run app.py local" > ${{ env.APP_NAME }}.bat
47+
48+
- name: Create All-in-one executable folder
49+
run: |
50+
mkdir streamlit_exe
51+
mv python-${{ env.PYTHON_VERSION }} streamlit_exe
52+
cp -r src streamlit_exe
53+
cp -r content streamlit_exe
54+
cp -r docs streamlit_exe
55+
cp -r assets streamlit_exe
56+
cp -r example-data streamlit_exe
57+
cp -r .streamlit streamlit_exe
58+
cp app.py streamlit_exe
59+
cp settings.json streamlit_exe
60+
cp default-parameters.json streamlit_exe
61+
cp ${{ env.APP_NAME }}.bat streamlit_exe
62+
63+
- name: Generate Readme.txt
64+
shell: bash
65+
run: |
66+
cat <<EOF > streamlit_exe/Readme.txt
67+
Welcome to ${{ env.APP_NAME }} app!
68+
69+
To launch the application:
70+
1. Navigate to the installation directory.
71+
2. Double-click on the file: ${{ env.APP_NAME }}.bat or ${{ env.APP_NAME }} shortcut.
72+
73+
Additional Information:
74+
- If multiple Streamlit apps are running, you can change the port in the .streamlit/config.toml file.
75+
Example:
76+
[server]
77+
port = 8502
78+
79+
Reach out to us:
80+
- Join our Discord server for support and community discussions: https://discord.com/invite/4TAGhqJ7s5
81+
- Contribute or stay updated with the latest OpenMS web app developments on GitHub: https://github.com/OpenMS/streamlit-template
82+
- Visit our website for more information: https://openms.de/
83+
84+
Thank you for using ${{ env.APP_NAME }}!
85+
EOF
86+
87+
- name: Install WiX Toolset
88+
run: |
89+
curl -LO https://github.com/wixtoolset/wix3/releases/download/wix3111rtm/wix311-binaries.zip
90+
unzip wix311-binaries.zip -d wix
91+
rm wix311-binaries.zip
92+
93+
- name: Build .wxs for streamlit_exe folder
94+
run: |
95+
./wix/heat.exe dir streamlit_exe -gg -sfrag -sreg -srd -template component -cg StreamlitExeFiles -dr AppSubFolder -out streamlit_exe_files.wxs
96+
97+
- name: Generate VBScript file
98+
shell: bash
99+
run: |
100+
cat <<EOF > ShowSuccessMessage.vbs
101+
MsgBox " The ${{ env.APP_NAME }} application is successfully installed.", vbInformation, "Installation Complete"
102+
EOF
103+
104+
- name: Prepare SourceDir
105+
run: |
106+
mkdir SourceDir
107+
mv streamlit_exe/* SourceDir
108+
cp ShowSuccessMessage.vbs SourceDir
109+
cp assets/openms_license.rtf SourceDir
110+
# Logo of app
111+
cp assets/openms.ico SourceDir
112+
113+
- name: Generate WiX XML file
114+
shell: bash
115+
run: |
116+
cat <<EOF > streamlit_exe.wxs
117+
<?xml version="1.0"?>
118+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
119+
<Product Id="*" Name="${{ env.APP_NAME }}" Language="1033" Version="1.0.0.0" Codepage="1252" Manufacturer="OpenMS Developer Team" UpgradeCode="${{ env.APP_UpgradeCode }}">
120+
<Package Id="*" InstallerVersion="300" Compressed="yes" InstallPrivileges="elevated" Platform="x64" />
121+
<Media Id="1" Cabinet="streamlit.cab" EmbedCab="yes" />
122+
123+
<!-- Folder structure -->
124+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
125+
<Directory Id="TARGETDIR" Name="SourceDir">
126+
<Directory Id="ProgramFilesFolder">
127+
<Directory Id="INSTALLFOLDER" Name="${{ env.APP_NAME }}">
128+
<Directory Id="AppSubFolder" Name="${{ env.APP_NAME }}" />
129+
<Component Id="CreateAppFolder" Guid="95dbfa06-d36a-427f-995c-e87769ac2e59">
130+
<CreateFolder>
131+
<Permission User="Everyone" GenericAll="yes" />
132+
</CreateFolder>
133+
</Component>
134+
</Directory>
135+
</Directory>
136+
<Directory Id="DesktopFolder" />
137+
</Directory>
138+
139+
<!-- Add components -->
140+
<Feature Id="MainFeature" Title="Main Application" Level="1">
141+
<ComponentGroupRef Id="StreamlitExeFiles" />
142+
<ComponentRef Id="CreateAppFolder" />
143+
<ComponentRef Id="DesktopShortcutComponent" />
144+
<ComponentRef Id="InstallDirShortcutComponent" />
145+
</Feature>
146+
147+
<!-- Create shortcut for running app on desktop -->
148+
<Component Id="DesktopShortcutComponent" Guid="3597b243-9180-4d0b-b105-30d8b0d1a334" Directory="DesktopFolder">
149+
<Shortcut Id="DesktopShortcut" Name="${{ env.APP_NAME }}" Description="Launch ${{ env.APP_NAME }}" Target="[AppSubFolder]${{ env.APP_NAME }}.bat" WorkingDirectory="AppSubFolder" Icon="AppIcon" />
150+
<RegistryValue Root="HKCU" Key="Software\\OpenMS\\${{ env.APP_NAME }}" Name="DesktopShortcut" Type="integer" Value="1" KeyPath="yes" />
151+
</Component>
152+
153+
<!-- Create shortcut for running app in installer folder -->
154+
<Component Id="InstallDirShortcutComponent" Guid="c2df9472-3b45-4558-a56d-6034cf7c8b72" Directory="AppSubFolder">
155+
<Shortcut Id="InstallDirShortcut" Name="${{ env.APP_NAME }}" Description="Launch ${{ env.APP_NAME }}" Target="[AppSubFolder]${{ env.APP_NAME }}.bat" WorkingDirectory="AppSubFolder" Icon="AppIcon" />
156+
<RegistryValue Root="HKCU" Key="Software\\OpenMS\\${{ env.APP_NAME }}" Name="InstallFolderShortcut" Type="integer" Value="1" KeyPath="yes" />
157+
</Component>
158+
159+
<!-- Provide icon here; it should exist in the SourceDir folder -->
160+
<Icon Id="AppIcon" SourceFile="SourceDir/openms.ico" />
161+
162+
<!-- Run app directly after installation -->
163+
<!-- <CustomAction Id="RunApp" Directory="AppSubFolder" Execute="deferred" Return="asyncNoWait" Impersonate="no"
164+
ExeCommand="cmd.exe /c &quot;[AppSubFolder]${{ env.APP_NAME }}.bat&quot;" /> -->
165+
166+
<!-- Custom Action to Show Success Message -->
167+
<Binary Id="ShowMessageScript" SourceFile="SourceDir/ShowSuccessMessage.vbs" />
168+
<CustomAction Id="ShowSuccessMessage" BinaryKey="ShowMessageScript" VBScriptCall="" Execute="immediate" Return="check" />
169+
170+
<!-- Add all Custom Actions -->
171+
<InstallExecuteSequence>
172+
<!-- Custom action display success message -->
173+
<Custom Action="ShowSuccessMessage" After="InstallFinalize">NOT Installed</Custom>
174+
<!-- Run app directly after installation -->
175+
<!-- <Custom Action="RunApp" Before="InstallFinalize">NOT REMOVE</Custom> -->
176+
</InstallExecuteSequence>
177+
178+
<!-- Interface options -->
179+
<UI>
180+
<UIRef Id="WixUI_InstallDir" />
181+
<UIRef Id="WixUI_ErrorProgressText" />
182+
</UI>
183+
184+
<!-- Provide license; it should exist in the SourceDir folder -->
185+
<WixVariable Id="WixUILicenseRtf" Value="SourceDir/openms_license.rtf" />
186+
</Product>
187+
</Wix>
188+
EOF
189+
190+
- name: Build .wixobj file with candle.exe
191+
run: |
192+
./wix/candle.exe streamlit_exe.wxs streamlit_exe_files.wxs
193+
194+
- name: Link .wixobj file into .msi with light.exe
195+
run: |
196+
./wix/light.exe -ext WixUIExtension -sice:ICE60 -o ${{ env.APP_NAME }}.msi streamlit_exe_files.wixobj streamlit_exe.wixobj
197+
198+
- name: Archive build artifacts
199+
uses: actions/upload-artifact@v4
200+
with:
201+
name: OpenMS-App-Test
202+
path: |
203+
${{ env.APP_NAME }}.msi

0 commit comments

Comments
 (0)