-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux/PyInstaller: Exclude unneeded libraries #366
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can merge this easily, but I wanted to point out that PyInstaller has other ways of doing this, it seems. Specifically, the Analysis
class has an excludes
option, that looks simpler to use: https://stackoverflow.com/a/42249386/8576445
There's also this: https://pyinstaller.org/en/stable/advanced-topics.html?highlight=Analysis#the-tree-class
Please consider using them instead of "subtracting" a TOC
instance.
I tried this: diff --git a/build.spec b/build.spec
index f61095d..103485a 100644
--- a/build.spec
+++ b/build.spec
@@ -65,7 +65,7 @@ a = Analysis(
["main.py"],
pathex=[],
datas=datas,
- excludes=[],
+ excludes=["libicudata.so.66", "libicuuc.so.66", "librsvg-2.so.2"],
hookspath=[],
noarchive=False,
runtime_hooks=[], But it didn't work. If I understand the documentation correctly,
This one I couldn't quite understand how to use in our case, sorry... :(
How about this approach: diff --git a/build.spec b/build.spec
index e9d235f..080c00d 100644
--- a/build.spec
+++ b/build.spec
@@ -76,6 +76,13 @@ a = Analysis(
win_private_assemblies=False,
win_no_prefer_redirects=False,
)
+# Exclude unneeded Linux libraries
+excluded_binaries = [
+ "libicudata.so.66",
+ "libicuuc.so.66",
+ "librsvg-2.so.2"
+]
+a.binaries = TOC([x for x in a.binaries if x[0] not in excluded_binaries])
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
Which I got from here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excluding these Linux libraries doesn't seem to cause any side-effects at runtime (they're also not present in the AppImage). And the benefit of this, is a reduction of 15 MiB in the final size of the Linux binary, which should also slightly reduce the app's startup time (but don't quote me on that). :)
605541c
to
abf857a
Compare
Very well 🙂 |
Excluding these Linux libraries doesn't seem to cause any side-effects at runtime (they're also not present in the AppImage).
And the benefit of this, is a reduction of 15 MiB in the final size of the Linux binary, which should also slightly reduce the app's startup time (but don't quote me on that). :)