From 2c7b89936afb0ebc03d79f9505daa901c1a8a003 Mon Sep 17 00:00:00 2001 From: Laurent LAPORTE <43534797+laurent-laporte-pro@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:18:54 +0200 Subject: [PATCH] fix(build): fix pyinstaller build (#1566) Signed-off-by: Sylvain Leclerc Co-authored-by: Sylvain Leclerc --- .github/workflows/deploy.yml | 12 ++++++------ AntaresWebLinux.spec | 16 +++++++++++++--- AntaresWebWin.spec | 16 +++++++++++++--- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0d0687ea8a..e21f1a33bb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ on: push: branches: - 'master' - + - 'hotfix/**' jobs: binary: @@ -11,7 +11,7 @@ jobs: strategy: max-parallel: 3 matrix: - os: [windows-latest, ubuntu-20.04] + os: [ windows-latest, ubuntu-20.04 ] steps: - name: Checkout github repo (+ download lfs dependencies) @@ -59,17 +59,17 @@ jobs: if: matrix.os == 'windows-latest' run: | git log -1 HEAD --format=%H > .\resources\commit_id - pyinstaller -F antarest\worker\archive_worker_service.py -n AntaresWebWorker --add-data ".\resources;.\resources" + pyinstaller -F antarest\worker\archive_worker_service.py -n AntaresWebWorker --add-data ".\resources;.\resources" --hidden-import 'pythonjsonlogger.jsonlogger' - name: Generate Linux worker binary if: matrix.os == 'ubuntu-20.04' run: | - git log -1 HEAD --format=%H > .\resources\commit_id - pyinstaller -F antarest/worker/archive_worker_service.py -n AntaresWebWorker --add-data resources:resources + git log -1 HEAD --format=%H > ./resources/commit_id + pyinstaller -F antarest/worker/archive_worker_service.py -n AntaresWebWorker --add-data resources:resources --hidden-import 'pythonjsonlogger.jsonlogger' - name: Packaging run: bash ./package_antares_web.sh working-directory: scripts - name: install changelog requirements - run : npm install -g auto-changelog + run: npm install -g auto-changelog - name: generate changelog file run: | auto-changelog -l false --hide-empty-releases diff --git a/AntaresWebLinux.spec b/AntaresWebLinux.spec index 7d9d38fc8f..9ef9c954ff 100644 --- a/AntaresWebLinux.spec +++ b/AntaresWebLinux.spec @@ -1,13 +1,23 @@ # -*- mode: python ; coding: utf-8 -*- - +from pathlib import Path block_cipher = None -antares_web_server_a = Analysis(['antarest/gui.py'], +# We need to analyze all alembic files to be sure the migration phase works fine +migrations_dir = Path('alembic/versions') +migration_files = [str(f) for f in migrations_dir.iterdir() if f.is_file() and f.suffix == '.py'] + +antares_web_server_a = Analysis(['antarest/gui.py', 'alembic/env.py'] + migration_files, pathex=[], binaries=[('./alembic.ini', './alembic.ini')], datas=[('./resources', './resources'), ('./alembic', './alembic')], - hiddenimports=['cmath', 'antarest.dbmodel', 'plyer.platforms.linux', 'plyer.platforms.linux.notification'], + hiddenimports=[ + 'cmath', + 'antarest.dbmodel', + 'plyer.platforms.linux', + 'plyer.platforms.linux.notification', + 'pythonjsonlogger.jsonlogger', + ], hookspath=['extra-hooks'], hooksconfig={}, runtime_hooks=[], diff --git a/AntaresWebWin.spec b/AntaresWebWin.spec index a91c594635..91fc74acb8 100644 --- a/AntaresWebWin.spec +++ b/AntaresWebWin.spec @@ -1,13 +1,23 @@ # -*- mode: python ; coding: utf-8 -*- - +from pathlib import Path block_cipher = None -antares_web_server_a = Analysis(['antarest/gui.py'], +# We need to analyze all alembic files to be sure the migration phase works fine +migrations_dir = Path('alembic/versions') +migration_files = [str(f) for f in migrations_dir.iterdir() if f.is_file() and f.suffix == '.py'] + +antares_web_server_a = Analysis(['antarest/gui.py', 'alembic/env.py'] + migration_files, pathex=[], binaries=[('./alembic.ini', './alembic.ini')], datas=[('./resources', './resources'), ('./alembic', './alembic')], - hiddenimports=['cmath', 'antarest.dbmodel', 'plyer.platforms.win', 'plyer.platforms.win.notification'], + hiddenimports=[ + 'cmath', + 'antarest.dbmodel', + 'plyer.platforms.win', + 'plyer.platforms.win.notification', + 'pythonjsonlogger.jsonlogger', + ], hookspath=['extra-hooks'], hooksconfig={}, runtime_hooks=[],