From b168ba831311fa40aceba1ebb3addae65c4cf331 Mon Sep 17 00:00:00 2001 From: Chidi Williams Date: Sun, 9 Oct 2022 23:24:38 +0100 Subject: [PATCH] Fix randomly opened windows in PyInstaller app (#38) --- .github/workflows/ci.yml | 8 +++++--- Makefile | 16 ++++++++++------ main.py | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ba38840..e3c1e9f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,13 +35,13 @@ jobs: - os: macos-latest CMD_BUILD: | brew install create-dmg - poetry run make bundle_mac version=$GITHUB_REF_NAME + poetry run make bundle_mac - os: ubuntu-latest CMD_BUILD: | - poetry run make bundle_linux version=$GITHUB_REF_NAME + poetry run make bundle_linux - os: windows-latest CMD_BUILD: | - poetry run make bundle_windows version=$env:GITHUB_REF_NAME + poetry run make bundle_windows steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 @@ -63,6 +63,8 @@ jobs: - run: poetry install - run: ${{ matrix.CMD_BUILD }} + env: + BUZZ_VERSION: ${{ github.ref_name }} - uses: actions/upload-artifact@v3 with: name: Buzz diff --git a/Makefile b/Makefile index 7d0cec74..9f32de76 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,11 @@ +mac_app_path := ./dist/Buzz.app +mac_zip_path := ./dist/Buzz-$$BUZZ_VERSION-mac.zip +mac_dmg_path := ./dist/Buzz-$$BUZZ_VERSION-mac.dmg + +unix_zip_path := ./dist/Buzz-$$BUZZ_VERSION-unix.tar.gz + +windows_zip_path := ./dist/Buzz-$$BUZZ_VERSION-windows.tar.gz + buzz: make clean pyinstaller --noconfirm Buzz.spec @@ -13,23 +21,19 @@ version: bundle_linux: make buzz - tar -czf dist/buzz-${version}-unix.tar.gz dist/Buzz + tar -czf ${unix_zip_path} dist/Buzz bundle_windows: make buzz - tar -czf dist/buzz-${version}-windows.tar.gz dist/Buzz + tar -czf ${windows_zip_path} dist/Buzz # MAC -mac_app_path := ./dist/Buzz.app -mac_zip_path := ./dist/Buzz-$$BUZZ_VERSION-mac.zip -mac_dmg_path := ./dist/Buzz-$$BUZZ_VERSION-mac.dmg bundle_mac: make buzz bundle_mac_local: - source .env make buzz make codesign_all_mac make zip_mac diff --git a/main.py b/main.py index dd3c0046..b0302004 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,12 @@ import logging +import multiprocessing from gui import Application if __name__ == "__main__": + # Stop PyInstaller from randomly opening multiple windows: https://stackoverflow.com/a/32677108/9830227 + multiprocessing.freeze_support() + logging.basicConfig( level=logging.DEBUG, format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s")