From e653c3df29355e84f5845d428d2265b902f5abeb Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Thu, 5 Oct 2023 21:27:51 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D1=8B=20=D0=B4=D0=BB=D1=8F=20QMessageBox=20(#73)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 3 +- .idea/misc.xml | 3 ++ README.md | 2 +- statapp-onefile.spec | 59 --------------------- statapp.spec | 96 +++++++++++++++++++++++++---------- statapp/__main__.py | 1 + 6 files changed, 76 insertions(+), 88 deletions(-) delete mode 100644 statapp-onefile.spec diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a134f4..9d208fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,8 @@ jobs: - name: Установка зависимостей run: poetry install - name: Сборка - run: poetry run pyinstaller ${{ matrix.spec }}.spec\ + if: + run: pyinstaller statapp.spec -- ${{ matrix.spec == 'statapp-onefile' && '--one-file' || '' }} - name: Архивация uses: thedoctor0/zip-release@0.7.1 with: diff --git a/.idea/misc.xml b/.idea/misc.xml index d20b033..19c19b7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + diff --git a/README.md b/README.md index d8432bd..b4a3564 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ ```bash poetry install -poetry run pyinstaller statapp.spec # или poetry run pyinstaller stat-onefile.spec +pyinstaller statapp.spec # или pyinstaller statapp.spec -- --one-file ``` ## Использование diff --git a/statapp-onefile.spec b/statapp-onefile.spec deleted file mode 100644 index 0b7f9d2..0000000 --- a/statapp-onefile.spec +++ /dev/null @@ -1,59 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- -import sys -import typing -from pprint import pprint - -if typing.TYPE_CHECKING: - from PyInstaller.building.api import COLLECT, EXE, MERGE, PYZ # noqa: F401 - from PyInstaller.building.build_main import Analysis # noqa: F401 - from PyInstaller.building.datastruct import TOC, Target, Tree # noqa: F401 - from PyInstaller.building.osx import BUNDLE # noqa: F401 - from PyInstaller.building.splash import Splash # noqa: F401 - -from PyInstaller.utils.hooks import copy_metadata - -datas = [('statapp/ui/images/*', 'ui/images')] -datas += copy_metadata('statapp') - -a = Analysis( - ['statapp/__main__.py'], - pathex=[], - binaries=[], - datas=datas, - hiddenimports=[], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - noarchive=False, -) - -prev_binaries = set(a.binaries) -if sys.platform in ('linux', 'darwin'): - a.exclude_system_libraries(list_of_exceptions=[]) # glob expression -print('\n\nSTRIPPED SYSTEM LIBS') -pprint(sorted(set(prev_binaries) - set(a.binaries))) - -pyz = PYZ(a.pure) - -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.datas, - [], - name='statapp', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=False, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, - icon='statapp/ui/images/logo.ico', -) diff --git a/statapp.spec b/statapp.spec index 66443f1..6142471 100644 --- a/statapp.spec +++ b/statapp.spec @@ -1,4 +1,5 @@ # -*- mode: python ; coding: utf-8 -*- +import argparse import sys import typing from pprint import pprint @@ -12,6 +13,10 @@ if typing.TYPE_CHECKING: from PyInstaller.utils.hooks import copy_metadata +parser = argparse.ArgumentParser() +parser.add_argument("--one-file", action="store_true") +options = parser.parse_args() + datas = [('statapp/ui/images/*', 'ui/images')] datas += copy_metadata('statapp') @@ -35,32 +40,69 @@ if sys.platform in ('linux', 'darwin'): print('\n\nSTRIPPED SYSTEM LIBS') pprint(sorted(set(prev_binaries) - set(a.binaries))) +LOCALES = ['ru', 'en'] +def remove_unused_translation(item): + dest = str(item[0]) + if not dest.startswith('PySide2/Qt/translations'): + return True + + for l in LOCALES: + if l in dest: + return True + + return False + +a.datas = list(filter(remove_unused_translation, a.datas)) + pyz = PYZ(a.pure) -exe = EXE( - pyz, - a.scripts, - [], - exclude_binaries=True, - name='statapp', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - console=False, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, - icon='statapp/ui/images/logo.ico', -) -coll = COLLECT( - exe, - a.binaries, - a.datas, - strip=False, - upx=True, - upx_exclude=[], - name='statapp', -) +if options.one_file: + exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='statapp', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon='statapp/ui/images/logo.ico', + ) +else: + exe = EXE( + pyz, + a.scripts, + [], + exclude_binaries=True, + name='statapp', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon='statapp/ui/images/logo.ico', + ) + coll = COLLECT( + exe, + a.binaries, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='statapp', + ) diff --git a/statapp/__main__.py b/statapp/__main__.py index b106134..85a118a 100644 --- a/statapp/__main__.py +++ b/statapp/__main__.py @@ -32,6 +32,7 @@ def main(): locale = QtCore.QLocale.system().name() path = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath) translator.load(f'qt_{locale}', path) + translator.load(f'qtbase_{locale}', path) app.installTranslator(translator) window = MainWindow()