Skip to content

Commit ea0744e

Browse files
committed
Fix Windows builds: use system Python to compile packages into embeddable target
The embeddable Python lacks development headers (Python.h) needed to compile native extensions like pyprophet. Use actions/setup-python to get a full Python installation for compiling, then install packages with --target pointing to the embeddable Python's site-packages.
1 parent 949b558 commit ea0744e

2 files changed

Lines changed: 37 additions & 36 deletions

File tree

.github/workflows/build-windows-executable-app.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,9 @@ jobs:
245245
run: |
246246
sed -i 's/#import site/import site/' python-${{ env.PYTHON_VERSION }}/python311._pth
247247
248-
- name: Install build dependencies (required for pyprophet build)
249-
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install cython numpy --no-warn-script-location
250-
251-
- name: Install Required Packages
252-
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install --force-reinstall -r requirements.txt --no-warn-script-location
248+
- name: Install Required Packages (using system Python to compile, targeting embeddable)
249+
run: |
250+
python -m pip install -r requirements.txt --target python-${{ env.PYTHON_VERSION }}/Lib/site-packages --upgrade
253251
254252
- name: Set to offline deployment
255253
run: |

.github/workflows/test-win-exe-w-embed-py.yaml

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Test streamlit executable for Windows with embeddable python
2-
on:
2+
on:
33
push:
44
branches: [ "main" ]
55
workflow_dispatch:
@@ -17,37 +17,40 @@ jobs:
1717
- name: Checkout code
1818
uses: actions/checkout@v4
1919

20+
- name: Set up Python (for building packages with native extensions)
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ env.PYTHON_VERSION }}
24+
2025
- name: Download python embeddable version
2126
run: |
2227
mkdir python-${{ env.PYTHON_VERSION }}
2328
curl -O https://www.python.org/ftp/python/${{ env.PYTHON_VERSION }}/python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
2429
unzip python-${{ env.PYTHON_VERSION }}-embed-amd64.zip -d python-${{ env.PYTHON_VERSION }}
2530
rm python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
2631
27-
- name: Install pip
32+
- name: Install pip in embeddable Python
2833
run: |
2934
curl -O https://bootstrap.pypa.io/get-pip.py
3035
./python-${{ env.PYTHON_VERSION }}/python get-pip.py --no-warn-script-location
3136
rm get-pip.py
32-
37+
3338
- name: Uncomment 'import site' in python311._pth file
3439
run: |
3540
sed -i 's/#import site/import site/' python-${{ env.PYTHON_VERSION }}/python311._pth
36-
41+
3742
- name: Print content of python311._pth file
3843
run: |
3944
cat python-${{ env.PYTHON_VERSION }}/python311._pth
4045
41-
- name: Install build dependencies (required for pyprophet build)
42-
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install cython numpy --no-warn-script-location
46+
- name: Install Required Packages (using system Python to compile, targeting embeddable)
47+
run: |
48+
python -m pip install -r requirements.txt --target python-${{ env.PYTHON_VERSION }}/Lib/site-packages --upgrade
4349
44-
- name: Install Required Packages
45-
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install -r requirements.txt --no-warn-script-location
46-
4750
- name: Create .bat file
4851
run: |
4952
echo " start /min .\python-${{ env.PYTHON_VERSION }}\python -m streamlit run app.py local" > ${{ env.APP_NAME }}.bat
50-
53+
5154
- name: Create All-in-one executable folder
5255
run: |
5356
mkdir streamlit_exe
@@ -62,7 +65,7 @@ jobs:
6265
cp settings.json streamlit_exe
6366
cp default-parameters.json streamlit_exe
6467
cp ${{ env.APP_NAME }}.bat streamlit_exe
65-
68+
6669
- name: Generate Readme.txt
6770
shell: bash
6871
run: |
@@ -83,20 +86,20 @@ jobs:
8386
- Join our Discord server for support and community discussions: https://discord.com/invite/4TAGhqJ7s5
8487
- Contribute or stay updated with the latest OpenMS web app developments on GitHub: https://github.com/OpenMS/streamlit-template
8588
- Visit our website for more information: https://openms.de/
86-
89+
8790
Thank you for using ${{ env.APP_NAME }}!
8891
EOF
89-
92+
9093
- name: Install WiX Toolset
9194
run: |
9295
curl -LO https://github.com/wixtoolset/wix3/releases/download/wix3111rtm/wix311-binaries.zip
9396
unzip wix311-binaries.zip -d wix
9497
rm wix311-binaries.zip
95-
98+
9699
- name: Build .wxs for streamlit_exe folder
97100
run: |
98101
./wix/heat.exe dir streamlit_exe -gg -sfrag -sreg -srd -template component -cg StreamlitExeFiles -dr AppSubFolder -out streamlit_exe_files.wxs
99-
102+
100103
- name: Generate VBScript file
101104
shell: bash
102105
run: |
@@ -112,7 +115,7 @@ jobs:
112115
cp assets/openms_license.rtf SourceDir
113116
# Logo of app
114117
cp assets/openms.ico SourceDir
115-
118+
116119
- name: Generate WiX XML file
117120
shell: bash
118121
run: |
@@ -122,13 +125,13 @@ jobs:
122125
<Product Id="*" Name="${{ env.APP_NAME }}" Language="1033" Version="1.0.0.0" Codepage="1252" Manufacturer="OpenMS Developer Team" UpgradeCode="${{ env.APP_UpgradeCode }}">
123126
<Package Id="*" InstallerVersion="300" Compressed="yes" InstallPrivileges="elevated" Platform="x64" />
124127
<Media Id="1" Cabinet="streamlit.cab" EmbedCab="yes" />
125-
128+
126129
<!-- Folder structure -->
127130
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
128131
<Directory Id="TARGETDIR" Name="SourceDir">
129-
<Directory Id="ProgramFilesFolder">
132+
<Directory Id="ProgramFilesFolder">
130133
<Directory Id="INSTALLFOLDER" Name="${{ env.APP_NAME }}">
131-
<Directory Id="AppSubFolder" Name="${{ env.APP_NAME }}" />
134+
<Directory Id="AppSubFolder" Name="${{ env.APP_NAME }}" />
132135
<Component Id="CreateAppFolder" Guid="95dbfa06-d36a-427f-995c-e87769ac2e59">
133136
<CreateFolder>
134137
<Permission User="Everyone" GenericAll="yes" />
@@ -138,52 +141,52 @@ jobs:
138141
</Directory>
139142
<Directory Id="DesktopFolder" />
140143
</Directory>
141-
144+
142145
<!-- Add components -->
143146
<Feature Id="MainFeature" Title="Main Application" Level="1">
144147
<ComponentGroupRef Id="StreamlitExeFiles" />
145148
<ComponentRef Id="CreateAppFolder" />
146149
<ComponentRef Id="DesktopShortcutComponent" />
147150
<ComponentRef Id="InstallDirShortcutComponent" />
148151
</Feature>
149-
152+
150153
<!-- Create shortcut for running app on desktop -->
151154
<Component Id="DesktopShortcutComponent" Guid="3597b243-9180-4d0b-b105-30d8b0d1a334" Directory="DesktopFolder">
152155
<Shortcut Id="DesktopShortcut" Name="${{ env.APP_NAME }}" Description="Launch ${{ env.APP_NAME }}" Target="[AppSubFolder]${{ env.APP_NAME }}.bat" WorkingDirectory="AppSubFolder" Icon="AppIcon" />
153156
<RegistryValue Root="HKCU" Key="Software\\OpenMS\\${{ env.APP_NAME }}" Name="DesktopShortcut" Type="integer" Value="1" KeyPath="yes" />
154157
</Component>
155-
158+
156159
<!-- Create shortcut for running app in installer folder -->
157160
<Component Id="InstallDirShortcutComponent" Guid="c2df9472-3b45-4558-a56d-6034cf7c8b72" Directory="AppSubFolder">
158161
<Shortcut Id="InstallDirShortcut" Name="${{ env.APP_NAME }}" Description="Launch ${{ env.APP_NAME }}" Target="[AppSubFolder]${{ env.APP_NAME }}.bat" WorkingDirectory="AppSubFolder" Icon="AppIcon" />
159162
<RegistryValue Root="HKCU" Key="Software\\OpenMS\\${{ env.APP_NAME }}" Name="InstallFolderShortcut" Type="integer" Value="1" KeyPath="yes" />
160163
</Component>
161-
164+
162165
<!-- Provide icon here; it should exist in the SourceDir folder -->
163166
<Icon Id="AppIcon" SourceFile="SourceDir/openms.ico" />
164-
167+
165168
<!-- Run app directly after installation -->
166169
<!-- <CustomAction Id="RunApp" Directory="AppSubFolder" Execute="deferred" Return="asyncNoWait" Impersonate="no"
167170
ExeCommand="cmd.exe /c &quot;[AppSubFolder]${{ env.APP_NAME }}.bat&quot;" /> -->
168-
171+
169172
<!-- Custom Action to Show Success Message -->
170173
<Binary Id="ShowMessageScript" SourceFile="SourceDir/ShowSuccessMessage.vbs" />
171174
<CustomAction Id="ShowSuccessMessage" BinaryKey="ShowMessageScript" VBScriptCall="" Execute="immediate" Return="check" />
172-
175+
173176
<!-- Add all Custom Actions -->
174177
<InstallExecuteSequence>
175178
<!-- Custom action display success message -->
176179
<Custom Action="ShowSuccessMessage" After="InstallFinalize">NOT Installed</Custom>
177180
<!-- Run app directly after installation -->
178181
<!-- <Custom Action="RunApp" Before="InstallFinalize">NOT REMOVE</Custom> -->
179182
</InstallExecuteSequence>
180-
183+
181184
<!-- Interface options -->
182185
<UI>
183186
<UIRef Id="WixUI_InstallDir" />
184187
<UIRef Id="WixUI_ErrorProgressText" />
185-
</UI>
186-
188+
</UI>
189+
187190
<!-- Provide license; it should exist in the SourceDir folder -->
188191
<WixVariable Id="WixUILicenseRtf" Value="SourceDir/openms_license.rtf" />
189192
</Product>
@@ -193,7 +196,7 @@ jobs:
193196
- name: Build .wixobj file with candle.exe
194197
run: |
195198
./wix/candle.exe streamlit_exe.wxs streamlit_exe_files.wxs
196-
199+
197200
- name: Link .wixobj file into .msi with light.exe
198201
run: |
199202
./wix/light.exe -ext WixUIExtension -sice:ICE60 -o ${{ env.APP_NAME }}.msi streamlit_exe_files.wixobj streamlit_exe.wixobj
@@ -203,4 +206,4 @@ jobs:
203206
with:
204207
name: OpenMS-App-Test
205208
path: |
206-
${{ env.APP_NAME }}.msi
209+
${{ env.APP_NAME }}.msi

0 commit comments

Comments
 (0)