From 16dc7b4047031ed93504670c4d995d15d5c69aee Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 22 Jun 2024 16:37:14 -0300 Subject: [PATCH] build/windows: Debloat 'lib/python3.11' bundling After running almost all the py plug-ins, I noticed that few py modules and pkgs are used to justify the need of a slightly faster build time with .pyc. In the actual bloated status (with all .pyc), lib/python* is about 260 MB big. With the bare minimum .pyc after the tests above, python*/ is less than 90. So, let's purge the .pyc at bundling time (I'm not reinventing the wheel, Krita do this too), which reduces the .zip bundles (so the Inno and MSIX installs) in 170MB, the Installer .exe in 45MB and MSIX download in 60MB. --- Let's also disable any .pyc generation, since GIMP installed with Inno in the system-wide (aka admin) mode or installed with MSIX both doesn't handle well: py plug-ins work but have CLI errors, unlike Inno user-mode and .zip bundle. --- build/windows/gitlab-ci/3_bundle-gimp-uni_base.sh | 1 + build/windows/installer/base_gimp3264.iss | 2 -- data/environ/pygimp.env | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/windows/gitlab-ci/3_bundle-gimp-uni_base.sh b/build/windows/gitlab-ci/3_bundle-gimp-uni_base.sh index 27e83c6db2..b31317f60f 100644 --- a/build/windows/gitlab-ci/3_bundle-gimp-uni_base.sh +++ b/build/windows/gitlab-ci/3_bundle-gimp-uni_base.sh @@ -157,6 +157,7 @@ if [ "$CI_JOB_NAME" != 'gimp-win-x64-cross' ]; then bundle "$MSYS_PREFIX" bin/python*.exe bundle "$MSYS_PREFIX" lib/python*/ + clean "$GIMP_DISTRIB" lib/python*/*.pyc else # Just to ensure there is no introspected files that will output annoying warnings # This is needed because meson.build files can have flaws diff --git a/build/windows/installer/base_gimp3264.iss b/build/windows/installer/base_gimp3264.iss index a027fd14ae..e37c214ef8 100644 --- a/build/windows/installer/base_gimp3264.iss +++ b/build/windows/installer/base_gimp3264.iss @@ -476,8 +476,6 @@ Root: HKA; Subkey: "Software\GIMP {#GIMP_APP_VERSION}\Capabilities\FileAssociati Type: files; Name: "{app}\uninst\uninst.inf" Type: files; Name: "{app}\lib\gimp\{#GIMP_API_VERSION}\interpreters\lua.interp" Type: files; Name: "{app}\lib\gimp\{#GIMP_API_VERSION}\environ\pygimp.env" -;need to clean out all the generated .pyc files -Type: filesandordirs; Name: "{app}\Python\*" [Code] diff --git a/data/environ/pygimp.env b/data/environ/pygimp.env index e8bd2353fa..3572a9e88c 100644 --- a/data/environ/pygimp.env +++ b/data/environ/pygimp.env @@ -1 +1,2 @@ __COMPAT_LAYER=HIGHDPIAWARE +PYTHONDONTWRITEBYTECODE=1