Skip to content

Commit 018f044

Browse files
authored
Add workflow for building embeddable Python environment
This workflow builds an embeddable Python environment for the OpenMS-NuXLApp, including setup, package installation, and artifact creation.
1 parent b91def3 commit 018f044

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Build embeddable python env with App
2+
on:
3+
#push:
4+
# branches:
5+
# - main
6+
# - development
7+
pull_request:
8+
branches: [ "main" ]
9+
workflow_dispatch:
10+
11+
env:
12+
PYTHON_VERSION: 3.10.0
13+
14+
jobs:
15+
build-executable:
16+
runs-on: windows-2022
17+
18+
env:
19+
PYTHON_VERSION: 3.10.0
20+
APP_NAME: OpenMS-NuXLApp
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python (regular distribution)
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ env.PYTHON_VERSION }} # Use the same version as the embeddable version
30+
31+
- name: Setup python embeddable version
32+
run: |
33+
# Create a directory for the embeddable Python version
34+
mkdir python-${{ env.PYTHON_VERSION }}
35+
36+
# Download and unzip the embeddable Python version
37+
curl -O https://www.python.org/ftp/python/${{ env.PYTHON_VERSION }}/python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
38+
unzip python-${{ env.PYTHON_VERSION }}-embed-amd64.zip -d python-${{ env.PYTHON_VERSION }}
39+
rm python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
40+
# Define paths for the regular Python distribution and the embeddable distribution
41+
$PYTHON_DIR="${{ runner.tool_cache }}/Python/${{ env.PYTHON_VERSION }}/x64" # Path from actions/setup-python
42+
$EMBED_DIR="python-${{ env.PYTHON_VERSION }}"
43+
44+
mkdir -p $EMBED_DIR/Lib/site-packages/tkinter
45+
mkdir -p $EMBED_DIR/tcl
46+
# Copy necessary Tkinter files from the regular Python distribution
47+
cp -r $PYTHON_DIR/Lib/tkinter/* $EMBED_DIR/Lib/site-packages/tkinter/
48+
cp -r $PYTHON_DIR/tcl/* $EMBED_DIR/tcl/
49+
cp $PYTHON_DIR/DLLs/_tkinter.pyd $EMBED_DIR/
50+
cp $PYTHON_DIR/DLLs/tcl86t.dll $EMBED_DIR/
51+
cp $PYTHON_DIR/DLLs/tk86t.dll $EMBED_DIR/
52+
53+
- name: Install pip
54+
run: |
55+
curl -O https://bootstrap.pypa.io/get-pip.py
56+
./python-${{ env.PYTHON_VERSION }}/python get-pip.py --no-warn-script-location
57+
rm get-pip.py
58+
59+
- name: Uncomment 'import site' in python310._pth file
60+
run: |
61+
sed -i 's/#import site/import site/' python-${{ env.PYTHON_VERSION }}/python310._pth
62+
63+
- name: Install Required Packages
64+
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install --force-reinstall -r requirements_embd_py310_win.txt --no-warn-script-location
65+
66+
- name: Binary-stable OpenMS stack
67+
run: |
68+
# Seed DLLs
69+
python -m pip install pyopenms==3.3.0
70+
71+
# Override Python bindings
72+
python -m pip install pyopenms==3.1.0
73+
74+
# Restore correct NumPy ABI
75+
python -m pip install numpy==1.22.4
76+
77+
- name: Set to offline deployment
78+
run: |
79+
$content = Get-Content -Raw settings.json | ConvertFrom-Json
80+
$content.online_deployment = $false
81+
$content | ConvertTo-Json -Depth 100 | Set-Content settings.json
82+
83+
- name: Create .bat file
84+
run: |
85+
echo " start /min .\python-${{ env.PYTHON_VERSION }}\python -m streamlit run app.py local" > ${{ env.APP_NAME }}.bat
86+
87+
- name: Create All-in-one executable folder
88+
run: |
89+
if (Test-Path -Path "streamlit_exe") {
90+
Remove-Item -Recurse -Force "streamlit_exe"
91+
}
92+
93+
mkdir streamlit_exe
94+
95+
mv python-${{ env.PYTHON_VERSION }} streamlit_exe
96+
cp -r src streamlit_exe
97+
cp -r content streamlit_exe
98+
cp -r assets streamlit_exe
99+
cp -r example-data streamlit_exe
100+
cp -r .streamlit streamlit_exe
101+
cp app.py streamlit_exe
102+
cp settings.json streamlit_exe
103+
cp ${{ env.APP_NAME }}.bat streamlit_exe
104+
105+
- name: Generate Readme.txt
106+
shell: bash
107+
run: |
108+
cat <<EOF > streamlit_exe/Readme.txt
109+
Welcome to ${{ env.APP_NAME }} app!
110+
To launch the application:
111+
1. Navigate to the installation directory.
112+
2. Double-click on the file: ${{ env.APP_NAME }}.bat or ${{ env.APP_NAME }} shortcut.
113+
Additional Information:
114+
- If multiple Streamlit apps are running, you can change the port in the .streamlit/config.toml file.
115+
Example:
116+
[server]
117+
port = 8502
118+
Reach out to us:
119+
- Join our Discord server for support and community discussions: https://discord.com/invite/4TAGhqJ7s5
120+
- Contribute or stay updated with the latest OpenMS web app developments on GitHub: https://github.com/OpenMS/streamlit-template
121+
- Checkout the ${{ env.APP_NAME }} on Github: https://github.com/Arslan-Siraj/nuxl-app
122+
- Visit our website for more information: https://openms.de/
123+
124+
Thanks for using ${{ env.APP_NAME }}!
125+
EOF
126+
127+
- name: Archive build artifacts
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: OpenMS_NuXLApp_without_Wix
131+
path: |
132+
streamlit_exe

0 commit comments

Comments
 (0)