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
    ├──                        ├──
    ...                                 ├──
    ├── share                           ├──
    │   ├── fontconfig                  ├──
    │   ├── glib-2.0                    ├──
    │   ├── icons                       ├──
    │   ├── locale                      ├──
    │   ├── mime                        ├──
    │   └── themes                      ├──
    ...                                 ├──
    ├──                         ├──
    ├──                      ├──
    ├── splash_gui                      ├──
    ├──                         ├──
    ├──                        ├──
    ├──                      ├──
    ├──                      ├── splash_gui
    ├──                         ├──
    ├──                  ├──
    └──                         └──

Except for the warnings the splash screen works normal

1 answer

  • answered 2018-03-11 12:58 Levi Lesches

    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\"

    In the current directory, a bunch of new folders will be made. Here's what to do with them:

    1. Your file will be in "dist", and will be called script_name (without ".py", of course
    2. The folders "dist" and "build" are unnecessary, as well as __pycache__ if it comes up
    3. Also, the file "script_name".spec will be created.