Pyinstaller produce massive folder
I'm using pyinstaller to pack a splash screen, these are the import of the python script:
import subprocess import time import sys import os import signal from multiprocessing import Process, Queue import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk, Pango
I use the following command to create the dist folder:
The problem is that the produced folder is 630Mb which is an overkill for just a splash screen program, so I investigated further and i find out that i could remove a LOT of files (the most heavy were the one in the share folder containing my themes, all of them) but more importantly i found out that the vast majority of dynamic libraries were useless.
With trial and error I managed to remove all the things that were not necessary (often generating a warning which i don't care because it is just a splash screen). Is there a direct way to avoid this mess? Briefly i want to keep just the file containing actual called functions.
This is the before and after clean situation:
630Mb 8Mb . . └── splash_gui └── splash_gui ├── array.so ├── binascii.so ... ├── _collections.so ├── share ├── cPickle.so │ ├── fontconfig ├── cStringIO.so │ ├── glib-2.0 ├── fcntl.so │ ├── icons ├── _functools.so │ ├── locale ├── gi._gi.so │ ├── mime ├── _io.so │ └── themes ├── itertools.so ... ├── libpython2.7.so.1.0 ├── _sha.so ├── math.so ├── _socket.so ├── _multiprocessing.so ├── splash_gui ├── operator.so ├── _ssl.so ├── _random.so ├── strop.so ├── select.so ├── _struct.so ├── _socket.so ├── termios.so ├── splash_gui ├── time.so ├── _struct.so ├── unicodedata.so ├── time.so └── zlib.so └── zlib.so
Except for the warnings the splash screen works normal
If a .exe file (and no other folders/files) is acceptable (really just try it out if you need to chack the file size), Here is my solution, running the command:
pyinstaller --onefile "directory\script_name.py"
In the current directory, a bunch of new folders will be made. Here's what to do with them:
- Your file will be in "dist", and will be called script_name (without ".py", of course
- The folders "dist" and "build" are unnecessary, as well as
__pycache__if it comes up
- Also, the file "script_name".spec will be created.