user26845598
user26845598

Reputation: 21

Experiencing Horrendous Startup Times for Nuitka Standalone Apps

I have a PySide6 GUI app that relies on several external modules and libraries such as NumPy, SciPy, MatPlotLib, and Pickle. There are no performance issues when run in Python but when I create a standalone app using Nuitka, the startup time is extremely slow (>1 min).

Here's the bash command I'm using to generate the standalone app (I am a Mac user):

python3 -m nuitka \
    --standalone \
    --macos-create-app-bundle \
    --enable-plugin=pyside6 \
    --include-qt-plugins=sensible,qmacstyle,platforms \
    --include-data-files=logo.png=logo.png \
    --include-data-files=logo.icns=logo.icns \
    --include-module=nifco \
    --include-module=libminpack \
    --include-package=antoineCalc \
    --include-package=orgProps \
    --include-package=dict2struct \
    --include-package=stripVLE \
    --include-package=RCM \
    --include-package=RCMplot \
    --macos-app-icon=logo.icns \
    --output-dir=dist \
    --macos-app-name=freeRCM \
    freeRCM.py

Once the program finally opens, performance is fine. It's only startup. My current theory is that the program is building with more bloat than needed. Here's how I'm importing my libraries/etc. in my main GUI app:

import sys
import os
import numpy as np
from PySide6.QtWidgets import (QApplication, QMainWindow, QWidget, QPushButton, QVBoxLayout,
                               QHBoxLayout,QLabel, QListWidget, QLineEdit, QComboBox, QFrame,
                               QTableWidget, QTableWidgetItem, QFileDialog, QMessageBox,
                               QInputDialog, QGridLayout, QSizePolicy, QSpacerItem)
from PySide6.QtCore import Qt, QSize
from PySide6.QtGui import QPixmap
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar
import pickle
from dict2struct import dict2struct
from RCM import RCM
from RCMplot import RCMplot

I've noticed that while running Nuitka, stuff like matplotlib.bezier, matplotlib.contour, scipy.interpolate, and more are being included which are definitely not needed. This is during pass 1 so I think most of this stuff gets deleted later on during app building (during the "Detecting Used DLLs stage), but just to be safe, what's the best way to get rid of bloat? The standalone executables end up being ~300MB. If not this, then any other suggestions as to how I might reduce my app's startup time? Thanks.

Upvotes: 2

Views: 183

Answers (0)

Related Questions