Reputation: 1350
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:
pyinstaller splash_gui.py
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
Upvotes: 1
Views: 4295
Reputation: 11
Pyinstaller packs all your installed librarieswith pip ,so you need to create a clean new virtual environment and only install packages that you need in that environment, when you do that install pyinstaller inside and run it
Upvotes: 1
Reputation: 1601
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:
__pycache__
if it comes upUpvotes: 0