forked from OpenMS/streamlit-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arslan
committed
May 8, 2024
1 parent
5b8d8da
commit 012e102
Showing
4 changed files
with
294 additions
and
63 deletions.
There are no files selected for viewing
253 changes: 253 additions & 0 deletions
253
.github/workflows/build-windows-executable-app-with-pyinstaller.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
name: Build executable for Windows with pyinstaller | ||
on: | ||
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: release/${{ env.OPENMS_VERSION }} | ||
path: 'OpenMS' | ||
|
||
- name: Install Qt | ||
uses: jurplel/install-qt-action@v3 | ||
with: | ||
version: '5.15.2' # 5.12.7 is broken https://bugreports.qt.io/browse/QTBUG-81715, > 5.15.2 is not available on official archives (https://github.com/miurahr/aqtinstall/issues/636) | ||
host: 'windows' # default: win64_msvc2017_64 | ||
target: 'desktop' | ||
install-deps: 'true' | ||
cache: 'false' | ||
aqtversion: '==3.1.*' | ||
|
||
# https://github.com/marketplace/actions/visual-studio-shell | ||
- name: Set up Visual Studio shell | ||
uses: egor-tensin/vs-shell@v2 | ||
with: | ||
arch: x64 | ||
|
||
- name: Setup build tools | ||
shell: bash | ||
run: | | ||
choco install ccache ninja cmake | ||
## GH CLI "SHOULD BE" installed. Sometimes I had to manually install nonetheless. Super weird. | ||
# https://github.com/actions/runner-images/blob/main/images/win/scripts/Installers/Install-GitHub-CLI.ps1 | ||
echo "C:/Program Files (x86)/GitHub CLI" >> $GITHUB_PATH | ||
- name: Extract branch/PR infos | ||
shell: bash | ||
run: | | ||
cd OpenMS | ||
RUN_NAME_LOCAL=$(echo ${GITHUB_REF#refs/heads/} | tr / -) | ||
echo "RUN_NAME=${RUN_NAME_LOCAL}" >> $GITHUB_ENV | ||
echo "BASE_REF=$(gh pr view --json baseRefName -q .baseRefName || echo ${RUN_NAME_LOCAL})" >> $GITHUB_ENV | ||
id: extract_branch | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Cache contrib | ||
id: cache-contrib-win | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ github.workspace }}/OpenMS/contrib | ||
key: ${{ runner.os }}-contrib3 | ||
|
||
- name: Load contrib build | ||
if: steps.cache-contrib-win.outputs.cache-hit != 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
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 | ||
with: | ||
path: .ccache | ||
key: ${{ runner.os }}-ccache-${{ env.RUN_NAME }}-${{ github.run_number }} | ||
# Restoring: From current branch, otherwise from base branch, otherwise from any branch. | ||
restore-keys: | | ||
${{ runner.os }}-ccache-${{ env.RUN_NAME }} | ||
${{ runner.os }}-ccache-${{ env.BASE_REF }} | ||
${{ runner.os }}-ccache- | ||
- name: Add THIRDPARTY | ||
shell: bash | ||
run: | | ||
# initialize THIRDPARTY | ||
cd OpenMS | ||
git submodule update --init THIRDPARTY | ||
cd .. | ||
# add third-party binaries to PATH | ||
# use flat THIRDPARTY structure | ||
mkdir -p _thirdparty | ||
cp -R OpenMS/THIRDPARTY/Windows/64bit/* _thirdparty/ | ||
cp -R OpenMS/THIRDPARTY/All/* _thirdparty/ | ||
# add third-party binaries to PATH | ||
for thirdpartytool in ${{ github.workspace }}/_thirdparty/* | ||
do | ||
echo $thirdpartytool >> $GITHUB_PATH | ||
done | ||
- name: Build Windows | ||
shell: bash | ||
run: | | ||
mkdir $GITHUB_WORKSPACE/OpenMS/bld/ | ||
ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/cibuild.cmake | ||
env: | ||
#OS_PREFIX_PATH: "${{ env.Qt5_DIR }}/lib/cmake;${{ env.Qt5_DIR }}" | ||
CONTRIB_BUILD_DIRECTORY: "${{ github.workspace }}/OpenMS/contrib" | ||
CI_PROVIDER: "GitHub-Actions" | ||
CMAKE_GENERATOR: "Ninja" | ||
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS" | ||
BUILD_NAME: "${{ env.RUN_NAME }}-Win64-class-topp-${{ github.run_number }}" | ||
ENABLE_STYLE_TESTING: "OFF" | ||
ENABLE_TOPP_TESTING: "ON" | ||
ENABLE_CLASS_TESTING: "ON" | ||
WITH_GUI: "ON" | ||
ADDRESS_SANITIZER: "Off" | ||
BUILD_TYPE: "Release" | ||
OPENMP: "Off" | ||
USE_STATIC_BOOST: "On" | ||
# BUILD_FLAGS: "-p:CL_MPCount=2" # For VS Generator and MSBuild | ||
BUILD_FLAGS: "-j2" # Ninja will otherwise use all cores (doesn't go well in GHA) | ||
CMAKE_CCACHE_EXE: "ccache" | ||
CCACHE_BASEDIR: ${{ github.workspace }} | ||
CCACHE_DIR: ${{ github.workspace }}/.ccache | ||
CCACHE_COMPRESS: true | ||
CCACHE_COMPRESSLEVEL: 12 | ||
CCACHE_MAXSIZE: 400M | ||
|
||
- name: Test Windows | ||
shell: bash | ||
run: $LAUNCHER ctest --output-on-failure -V -S $GITHUB_WORKSPACE/OpenMS/tools/ci/citest.cmake | ||
env: | ||
LAUNCHER: "" | ||
SOURCE_DIRECTORY: "${{ github.workspace }}/OpenMS" | ||
CI_PROVIDER: "GitHub-Actions" | ||
BUILD_NAME: "${{ env.RUN_NAME }}-Win64-class-topp-${{ github.run_number }}" | ||
|
||
- name: Upload TOPP tools as artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: OpenMS-bin | ||
path: OpenMS/bld/bin | ||
|
||
- name: Upload share as artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: OpenMS-share | ||
path: OpenMS/share | ||
|
||
build-executable: | ||
runs-on: windows-latest | ||
needs: build-openms | ||
|
||
env: | ||
PYTHON_VERSION: 3.11.0 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download TOPP tools as artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: OpenMS-bin | ||
path: openms-bin | ||
|
||
- name: Download share as artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
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 | ||
run: | | ||
python -m venv myenv | ||
call myenv\Scripts\activate.bat | ||
pip install -r requirements.txt | ||
pip install pyinstaller | ||
- name: Write function to cli.py | ||
shell: bash | ||
run: | | ||
head -n -2 D:/a/streamlit-template/streamlit-template/myenv/Lib/site-packages/streamlit/web/cli.py > temp_cli.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 | ||
run: | | ||
call myenv\Scripts\activate.bat | ||
pyinstaller --onefile --additional-hooks-dir ./hooks run_app.py --clean | ||
- name: Copy everything to dist directory | ||
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 app.py dist/ | ||
- name: Modify .spec file | ||
shell: bash | ||
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 | ||
- name: Delete OpenMS bin artifact | ||
uses: geekyeggo/delete-artifact@v2 | ||
with: | ||
name: OpenMS-bin | ||
|
||
- name: Delete OpenMS share artifact | ||
uses: geekyeggo/delete-artifact@v2 | ||
with: | ||
name: OpenMS-share | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: OpenMS-App | ||
path: dist |
This file contains 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
This file contains 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
This file contains 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