Skip to content

Commit

Permalink
update windows exe build action
Browse files Browse the repository at this point in the history
  • Loading branch information
axelwalter committed Jun 5, 2024
1 parent a676f35 commit 4b50fe0
Showing 1 changed file with 50 additions and 59 deletions.
109 changes: 50 additions & 59 deletions .github/workflows/build-windows-executable-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build-openms:
runs-on: windows-latest

env:
OPENMS_VERSION: 3.0.0

steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: OpenMS/OpenMS
ref: develop # take latest develop due to changes to SiriusAdapter
ref: release/${{ env.OPENMS_VERSION }}
path: 'OpenMS'

- name: Install Qt
Expand Down Expand Up @@ -61,11 +65,16 @@ jobs:

- name: Load contrib build
if: steps.cache-contrib-win.outputs.cache-hit != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd OpenMS/contrib
curl -o contribbld.tar.gz https://abibuilder.cs.uni-tuebingen.de/archive/openms/contrib/windows/x64/msvc-14.2/contrib_build.tar.gz
tar -xzf contribbld.tar.gz
rm contribbld.tar.gz
cd OpenMS/contrib
# Download the file using the URL fetched from GitHub
gh release download -R OpenMS/contrib --pattern 'contrib_build-Windows.tar.gz'
# Extract the archive
7z x -so contrib_build-Windows.tar.gz | 7z x -si -ttar
rm contrib_build-Windows.tar.gz
ls
- name: Setup ccache cache
uses: actions/cache@v3
Expand Down Expand Up @@ -169,67 +178,44 @@ jobs:
name: OpenMS-share
path: share

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup virtual environment
shell: cmd
- name: Setup python embeddable version
run: |
python -m venv myenv
call myenv\Scripts\activate.bat
pip install -r requirements.txt
mkdir python-${{ env.PYTHON_VERSION }}
curl -O https://www.python.org/ftp/python/${{ env.PYTHON_VERSION }}/python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
unzip python-${{ env.PYTHON_VERSION }}-embed-amd64.zip -d python-${{ env.PYTHON_VERSION }}
rm python-${{ env.PYTHON_VERSION }}-embed-amd64.zip
pip install pyinstaller
- name: Write function to cli.py
shell: bash
- name: Install pip
run: |
head -n -2 D:/a/streamlit-template/streamlit-template/myenv/Lib/site-packages/streamlit/web/cli.py > temp_cli.py
curl -O https://bootstrap.pypa.io/get-pip.py
./python-${{ env.PYTHON_VERSION }}/python get-pip.py --no-warn-script-location
rm get-pip.py
cat << EOF >> temp_cli.py
def _main_run_clExplicit(file, command_line, args=[], flag_options=[]):
main._is_running_with_streamlit = True
bootstrap.run(file, command_line, args, flag_options)
if __name__ == "__main__":
main()
EOF
mv temp_cli.py D:/a/streamlit-template/streamlit-template/myenv/Lib/site-packages/streamlit/web/cli.py
- name: Compile app with pyinstaller
shell: cmd
- name: Uncomment 'import site' in python311._pth file
run: |
call myenv\Scripts\activate.bat
pyinstaller --onefile --additional-hooks-dir ./hooks run_app.py --clean
sed -i 's/#import site/import site/' python-${{ env.PYTHON_VERSION }}/python311._pth
- name: Install Required Packages
run: .\python-${{ env.PYTHON_VERSION }}\python -m pip install --force-reinstall -r requirements.txt --no-warn-script-location

- name: Copy everything to dist directory
- name: Create run_app.bat file
run: |
cp -r .streamlit dist/.streamlit
cp -r pages dist/pages
cp -r src dist/src
cp -r assets dist/assets
cp -r example-data dist/example-data
cp -r openms-bin dist/bin
cp -r share dist/share
cp Home.py dist/
- name: Modify .spec file
shell: bash
echo '@echo off' > UmetaFlow.bat
echo '.\\python-${{ env.PYTHON_VERSION }}\\python -m streamlit run Home.py local' >> UmetaFlow.bat
- name: Create All-in-one executable folder
run: |
cp run_app_temp.spec run_app.spec
- name: Make executable
shell: cmd
run: |
call myenv\Scripts\activate.bat
pyinstaller run_app.spec --clean
mkdir streamlit_exe
mv python-${{ env.PYTHON_VERSION }} streamlit_exe
mv run_app.bat streamlit_exe
cp -r src streamlit_exe
cp -r pages streamlit_exe
cp -r assets streamlit_exe
cp -r example-data streamlit_exe
cp -r .streamlit streamlit_exe
cp -r openms-bin streamlit_exe/bin
cp -r share streamlit_exe/share
cp Home.py streamlit_exe
- name: Delete OpenMS bin artifact
uses: geekyeggo/delete-artifact@v2
Expand All @@ -240,9 +226,14 @@ jobs:
uses: geekyeggo/delete-artifact@v2
with:
name: OpenMS-share

- name: Compress streamlit_exe folder to OpenMS-App.zip
run: |
7z a OpenMS-App.zip ./streamlit_exe/* -r
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: UmetaFlow-App
path: dist
name: OpenMS-App
path: OpenMS-App.zip

0 comments on commit 4b50fe0

Please sign in to comment.