From ebd274848a0625f8e8c377152a73434810e6d851 Mon Sep 17 00:00:00 2001 From: Achal Bajpai <111895109+achalbajpai@users.noreply.github.com> Date: Wed, 5 Mar 2025 17:33:31 +0530 Subject: [PATCH 1/7] docs: Add manual MSI packaging documentation using WiX Toolset --- docs/win_exe_with_embed_py.md | 255 +++++++++++++++++++++++++++------- 1 file changed, 208 insertions(+), 47 deletions(-) diff --git a/docs/win_exe_with_embed_py.md b/docs/win_exe_with_embed_py.md index 6db6ceae..69824285 100644 --- a/docs/win_exe_with_embed_py.md +++ b/docs/win_exe_with_embed_py.md @@ -7,51 +7,51 @@ Here's a step-by-step guide: 1. Download a suitable Python embeddable version. For example, let's download Python 3.11.9: - ```bash - # use curl command or manually download - curl -O https://www.python.org/ftp/python/3.11.9/python-3.11.9-embed-amd64.zip - ``` + ```bash + # use curl command or manually download + curl -O https://www.python.org/ftp/python/3.11.9/python-3.11.9-embed-amd64.zip + ``` 2. Extract the downloaded zip file: - ```bash - mkdir python-3.11.9 + ```bash + mkdir python-3.11.9 - unzip python-3.11.9-embed-amd64.zip -d python-3.11.9 + unzip python-3.11.9-embed-amd64.zip -d python-3.11.9 - rm python-3.11.9-embed-amd64.zip - ``` + rm python-3.11.9-embed-amd64.zip + ``` ### Install pip 1. Download `get-pip.py`: - ```bash - # use curl command or manually download - curl -O https://bootstrap.pypa.io/get-pip.py - ``` + ```bash + # use curl command or manually download + curl -O https://bootstrap.pypa.io/get-pip.py + ``` 2. Install pip: - ```bash - ./python-3.11.9/python get-pip.py --no-warn-script-location + ```bash + ./python-3.11.9/python get-pip.py --no-warn-script-location - # no need anymore get-pip.py - rm get-pip.py - ``` + # no need anymore get-pip.py + rm get-pip.py + ``` ### Configure Python Environment 1. Uncomment 'import site' in the `._pth` file: - ```bash - # Uncomment to run site.main() automatically - # Remove hash from python-3.11.9/python311._pth file - import site + ```bash + # Uncomment to run site.main() automatically + # Remove hash from python-3.11.9/python311._pth file + import site - # Or use command - sed -i '/^\s*#\s*import\s\+site/s/^#//' python-3.11.9/python311._pth - ``` + # Or use command + sed -i '/^\s*#\s*import\s\+site/s/^#//' python-3.11.9/python311._pth + ``` ### Install Required Packages @@ -65,45 +65,206 @@ Install all required packages from `requirements.txt`: 1. Test by running app - ```batch - .\python-3.11.9\python -m streamlit run app.py - ``` + ```batch + .\python-3.11.9\python -m streamlit run app.py + ``` 2. Create a Clickable Shortcut - Create a `run_app.bat` file to make running the app easier: - - ```batch - echo @echo off > run_app.bat - echo .\\python-3.11.9\\python -m streamlit run app.py >> run_app.bat - ``` + Create a `run_app.bat` file to make running the app easier: + + ```batch + echo @echo off > run_app.bat + echo .\\python-3.11.9\\python -m streamlit run app.py >> run_app.bat + ``` ### Create one executable folder 1. Create a folder for your Streamlit app: - ```bash - mkdir ../streamlit_exe - ``` + ```bash + mkdir ../streamlit_exe + ``` 2. Copy environment and app files: - ```bash - # move Python environment folder - mv python-3.11.9 ../streamlit_exe + ```bash + # move Python environment folder + mv python-3.11.9 ../streamlit_exe + + # move run_app.bat file + mv run_app.bat ../streamlit_exe - # move run_app.bat file - mv run_app.bat ../streamlit_exe + # copy streamlit app files + cp -r src pages .streamlit assets example-data ../streamlit_exe + cp app.py ../streamlit_exe + ``` - # copy streamlit app files - cp -r src pages .streamlit assets example-data ../streamlit_exe - cp app.py ../streamlit_exe - ``` - #### 🚀 After successfully completing all these steps, the Streamlit app will be available by running the run_app.bat file. :pencil: You can still change the configuration of Streamlit app with .streamlit/config.toml file, e.g., provide a different port, change upload size, etc. ## Build executable in github action automatically + Automate the process of building executables for your project with the GitHub action example [Test streamlit executable for Windows with embeddable python](https://github.com/OpenMS/streamlit-template/blob/main/.github/workflows/test-win-exe-w-embed-py.yaml)
+ +## Create MSI Installer using WiX Toolset + +After creating your executable folder, you can package it into an MSI installer using WiX Toolset. Here's how: + +### 1. Set Environment Variables + +Set these variables for consistent naming throughout the process: + +```batch +set APP_NAME=OpenMS-StreamlitTemplateApp +set APP_UpgradeCode=4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb +``` + +### 2. Install WiX Toolset + +1. Download WiX Toolset binaries: + ```batch + curl -LO https://github.com/wixtoolset/wix3/releases/download/wix3111rtm/wix311-binaries.zip + unzip wix311-binaries.zip -d wix + ``` + +### 3. Prepare Installation Files + +1. Create a SourceDir structure: + + ```batch + mkdir SourceDir + move streamlit_exe\* SourceDir + ``` + +2. Create Readme.txt: + + ```batch + echo Welcome to %APP_NAME% app! > SourceDir\Readme.txt + echo. >> SourceDir\Readme.txt + echo To launch the application: >> SourceDir\Readme.txt + echo 1. Navigate to the installation directory. >> SourceDir\Readme.txt + echo 2. Double-click on the file: %APP_NAME%.bat or %APP_NAME% shortcut. >> SourceDir\Readme.txt + ``` + +3. Add necessary assets: + - Copy license file: `copy assets\openms_license.rtf SourceDir\` + - Copy app icon: `copy assets\openms.ico SourceDir\` + - Create success message script: + ```vbscript + ' ShowSuccessMessage.vbs + MsgBox "The " & "%APP_NAME%" & " application is successfully installed.", vbInformation, "Installation Complete" + ``` + +### 4. Generate WiX Source Files + +1. Generate component list from your files: + + ```batch + wix\heat.exe dir SourceDir -gg -sfrag -sreg -srd -template component -cg StreamlitExeFiles -dr AppSubFolder -out streamlit_exe_files.wxs + ``` + +2. Create main WiX configuration file (streamlit_exe.wxs): + + ```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOT Installed + + + + + + + ``` + +### 5. Build the MSI + +1. Compile WiX source files: + + ```batch + wix\candle.exe streamlit_exe.wxs streamlit_exe_files.wxs + ``` + +2. Link and create MSI: + ```batch + wix\light.exe -ext WixUIExtension -sice:ICE60 -o %APP_NAME%.msi streamlit_exe_files.wixobj streamlit_exe.wixobj + ``` + +### 6. Additional Notes + +- The generated MSI will create desktop and start menu shortcuts +- Installation requires elevated privileges +- A success message will be shown after installation +- The installer includes a proper license agreement page +- All files will be installed in Program Files by default + +For more detailed customization options, refer to the [WiX Toolset documentation](https://wixtoolset.org/documentation/). + +:warning: The `APP_UpgradeCode` GUID should be unique for your application. Generate a new one if you're creating a different app. From f08977019fd7f8de3ce9c7eca0399e367472fda2 Mon Sep 17 00:00:00 2001 From: Sakthi Ragavan Date: Wed, 5 Mar 2025 06:00:02 +0530 Subject: [PATCH 2/7] Update app name and version display from settings --Updated app.py to display the app name from settings.json. --Updated common.py to display the version in the web UI from settings.py. --- app.py | 7 ++++++- settings.json | 1 + src/common/common.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 2f863cde..3383aa47 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,16 @@ import streamlit as st from pathlib import Path +import json # For some reason the windows version only works if this is imported here import pyopenms +if "settings" not in st.session_state: + with open("settings.json", "r") as f: + st.session_state.settings = json.load(f) + if __name__ == '__main__': pages = { - "OpenMS Web App" : [ + f"{st.session_state.settings["app-name"]}" : [ st.Page(Path("content", "quickstart.py"), title="Quickstart", icon="👋"), st.Page(Path("content", "documentation.py"), title="Documentation", icon="📖"), ], diff --git a/settings.json b/settings.json index ced34071..469a9d85 100644 --- a/settings.json +++ b/settings.json @@ -1,6 +1,7 @@ { "app-name": "OpenMS WebApp Template", "github-user": "OpenMS", + "version": "1.0.2", "repository-name": "streamlit-template", "analytics": { "google-analytics": { diff --git a/src/common/common.py b/src/common/common.py index 8269f937..56cce1a0 100644 --- a/src/common/common.py +++ b/src/common/common.py @@ -341,6 +341,23 @@ def change_workspace(): ) else: st.session_state["spectrum_num_bins"] = 50 + + # Display OpenMS WebApp Template Version from settings.json + with st.container(): + st.markdown( + """ + + """, + unsafe_allow_html=True + ) + version_info = st.session_state.settings["version"] + st.markdown(f'
OpenMS WebApp: V{version_info}
', unsafe_allow_html=True) return params From 38a3136c1348727079dc4392412043facd9f7e08 Mon Sep 17 00:00:00 2001 From: Sakthi Ragavan Date: Wed, 5 Mar 2025 20:24:52 +0530 Subject: [PATCH 3/7] Updated the f string with str() function to display the app name --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 3383aa47..4952a8c8 100644 --- a/app.py +++ b/app.py @@ -10,7 +10,7 @@ if __name__ == '__main__': pages = { - f"{st.session_state.settings["app-name"]}" : [ + str(st.session_state.settings["app-name"]) : [ st.Page(Path("content", "quickstart.py"), title="Quickstart", icon="👋"), st.Page(Path("content", "documentation.py"), title="Documentation", icon="📖"), ], From a3206fb044283e2eebb1442702adb19389e24dec Mon Sep 17 00:00:00 2001 From: Sakthi Ragavan Date: Wed, 5 Mar 2025 22:08:09 +0530 Subject: [PATCH 4/7] Center text in the UI to display version . Implemented text centering for improved visual presentation within the designated version. --- src/common/common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/common.py b/src/common/common.py index 56cce1a0..58299c8e 100644 --- a/src/common/common.py +++ b/src/common/common.py @@ -350,14 +350,18 @@ def change_workspace(): .version-box { border: 1px solid #a4a5ad; padding: 10px; - border-radius: 0.5rem; + border-radius: 0.5rem; + text-align: center; + display: flex; + justify-content: center; + align-items: center; } """, unsafe_allow_html=True ) version_info = st.session_state.settings["version"] - st.markdown(f'
OpenMS WebApp: V{version_info}
', unsafe_allow_html=True) + st.markdown(f'
OpenMS WebApp: V{version_info}
', unsafe_allow_html=True) return params From ba2f4ea8019200f82025ae36e5eb3316bb918487 Mon Sep 17 00:00:00 2001 From: Sakthi Ragavan Date: Thu, 6 Mar 2025 14:21:09 +0530 Subject: [PATCH 5/7] updated the version display style as mentioned. {App name from settings.json} Version {Version number from settings.json} --- src/common/common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/common.py b/src/common/common.py index 58299c8e..c2c1bd7c 100644 --- a/src/common/common.py +++ b/src/common/common.py @@ -360,8 +360,9 @@ def change_workspace(): """, unsafe_allow_html=True ) - version_info = st.session_state.settings["version"] - st.markdown(f'
OpenMS WebApp: V{version_info}
', unsafe_allow_html=True) + version_info = st.session_state.settings["version"] + app_name = st.session_state.settings["app-name"] + st.markdown(f'
{app_name}
Version: V{version_info}
', unsafe_allow_html=True) return params From 440991e86baac0432854f4596d3e0f0d8beda8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20David=20M=C3=BCller?= <57191390+t0mdavid-m@users.noreply.github.com> Date: Thu, 6 Mar 2025 12:32:36 +0100 Subject: [PATCH 6/7] remove V from version box --- src/common/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/common.py b/src/common/common.py index c2c1bd7c..80430de0 100644 --- a/src/common/common.py +++ b/src/common/common.py @@ -362,7 +362,7 @@ def change_workspace(): ) version_info = st.session_state.settings["version"] app_name = st.session_state.settings["app-name"] - st.markdown(f'
{app_name}
Version: V{version_info}
', unsafe_allow_html=True) + st.markdown(f'
{app_name}
Version: {version_info}
', unsafe_allow_html=True) return params From 7f0600ac880004f509827b6799a268196e235705 Mon Sep 17 00:00:00 2001 From: Achal Bajpai <111895109+achalbajpai@users.noreply.github.com> Date: Sat, 8 Mar 2025 02:01:30 +0530 Subject: [PATCH 7/7] docs: Add explanatory comments for WiX Toolset commands --- docs/win_exe_with_embed_py.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/win_exe_with_embed_py.md b/docs/win_exe_with_embed_py.md index 69824285..35719958 100644 --- a/docs/win_exe_with_embed_py.md +++ b/docs/win_exe_with_embed_py.md @@ -118,10 +118,16 @@ After creating your executable folder, you can package it into an MSI installer Set these variables for consistent naming throughout the process: ```batch -set APP_NAME=OpenMS-StreamlitTemplateApp -set APP_UpgradeCode=4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb +APP_NAME=OpenMS-StreamlitTemplateApp +APP_UpgradeCode=4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb ``` +To create a new GUID for your application's UpgradeCode, you can use: + +- PowerShell: `[guid]::NewGuid().ToString()` +- Online GUID generator: https://www.guidgen.com/ +- Windows Command Prompt: `powershell -Command "[guid]::NewGuid().ToString()"` + ### 2. Install WiX Toolset 1. Download WiX Toolset binaries: @@ -142,11 +148,8 @@ set APP_UpgradeCode=4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb 2. Create Readme.txt: ```batch - echo Welcome to %APP_NAME% app! > SourceDir\Readme.txt - echo. >> SourceDir\Readme.txt - echo To launch the application: >> SourceDir\Readme.txt - echo 1. Navigate to the installation directory. >> SourceDir\Readme.txt - echo 2. Double-click on the file: %APP_NAME%.bat or %APP_NAME% shortcut. >> SourceDir\Readme.txt + # Create a Readme.txt file in the SourceDir folder with instructions + # for launching the application ``` 3. Add necessary assets: @@ -249,11 +252,14 @@ set APP_UpgradeCode=4abc2e23-3ba5-40e4-95c9-09e6cb8ecaeb 1. Compile WiX source files: ```batch + # Generate wixobj files from the WiX source files wix\candle.exe streamlit_exe.wxs streamlit_exe_files.wxs ``` 2. Link and create MSI: ```batch + # Create the MSI installer from the wixobj files + # The -sice:ICE60 flag stops a warning about duplicate component GUIDs, which can happen when heat.exe auto-generates components wix\light.exe -ext WixUIExtension -sice:ICE60 -o %APP_NAME%.msi streamlit_exe_files.wixobj streamlit_exe.wixobj ```