Update test-win-exe-w-embed-py.yaml #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |