From ed8c598180955f1d7fc39fa71925d86f17a22578 Mon Sep 17 00:00:00 2001 From: guihkx <626206+guihkx@users.noreply.github.com> Date: Sat, 10 Jun 2023 08:32:35 -0300 Subject: [PATCH] pyinstaller: avoid bundling icon and themes on Linux This greatly reduces the final size of the UPX-compressed binary, from 78.7 MiB to 54.9 MiB (a 23.8 MiB difference)! Co-authored-by: DevilXD --- build.spec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build.spec b/build.spec index c6d8d46..e9d235f 100644 --- a/build.spec +++ b/build.spec @@ -3,7 +3,7 @@ from __future__ import annotations import sys from pathlib import Path -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING SELF_PATH = str(Path(".").absolute()) if SELF_PATH not in sys.path: @@ -34,6 +34,7 @@ for source_path, dest_path, required in to_add: elif required: raise FileNotFoundError(str(source_path)) +hooksconfig: dict[str, Any] = {} binaries: list[tuple[Path, str]] = [] hiddenimports: list[str] = [ "PIL._tkinter_finder", @@ -51,6 +52,13 @@ if sys.platform == "linux": "gi.repository.Gtk", "gi.repository.GObject", ]) + hooksconfig = { + "gi": { + "icons": [], + "themes": [], + "languages": ["en_US"] + } + } block_cipher = None a = Analysis( @@ -59,11 +67,11 @@ a = Analysis( datas=datas, excludes=[], hookspath=[], - hooksconfig={}, noarchive=False, runtime_hooks=[], binaries=binaries, cipher=block_cipher, + hooksconfig=hooksconfig, hiddenimports=hiddenimports, win_private_assemblies=False, win_no_prefer_redirects=False,