Skip to content
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

Pyinstaller is pulling the whole Qt package in linux with PySide6 #6447

Closed
6 tasks done
xsun2001 opened this issue Dec 20, 2021 · 2 comments · Fixed by #6453
Closed
6 tasks done

Pyinstaller is pulling the whole Qt package in linux with PySide6 #6447

xsun2001 opened this issue Dec 20, 2021 · 2 comments · Fixed by #6453

Comments

@xsun2001
Copy link

Description of the issue

Context information (for bug reports)

  • Output of pyinstaller --version: 4.7

  • Version of Python: 3.9.7

  • Platform: Ubuntu 21.10 x86_64

  • How you installed Python: apt

  • Did you also try this on another platform? Does it work there? Both MacOS and Windows are good here.

  • try the latest development version, using the following command:

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

Make sure everything is packaged correctly

  • start with clean installation
  • use the latest development version
  • Run your frozen program from a command window (shell) — instead of double-clicking on it
  • Package your program in --onedir mode
  • Package without UPX, say: use the option --noupx or set upx=False in your .spec-file
  • Repackage you application in verbose/debug mode. For this, pass the option --debug to pyi-makespec or pyinstaller or use EXE(..., debug=1, ...) in your .spec file.

A minimal example program which shows the error

Init a clean workspace

python3 -m venv ./venv
source ./venv/bin/activate
pip install pyside6 pyinstaller

PySide6 version info:

$ python
>>> import PySide6
>>> PySide6.__version__
'6.2.2.1'
>>> from PySide6 import QtCore
>>> QtCore.__version__
'6.2.2'

Just a "helloworld" example from PySide6 document

import sys
from PySide6.QtWidgets import QApplication, QLabel

app = QApplication(sys.argv)
label = QLabel("Hello World!")
label.show()
app.exec()

Package it

$ pyinstaller main.py -w

In linux environment described above, pyinstaller produces a >600MB directory, which includes a lot of unused but huge Qt libraries such as libQt6WebEngineCore.so.6(175.9MB). In contrast, pyinstaller in MacOS produces a 86.9MB directory with only necessary libraries inside.

@xsun2001 xsun2001 added the triage Please triage and relabel this issue label Dec 20, 2021
@rokm
Copy link
Member

rokm commented Dec 20, 2021

Hmm, that's actually PyInstaller's dependency resolution working as intended...

The problem is that in linux PySide6 wheels, all extension modules (e.g., site-packages/PySide6/QtCore.abi3.so) are for some reason linked against libQt6Qml.so.6, which causes PyInstaller to pull in PySide6.QtQml. And because we have no way of tracking QML imports and dependencies, we collect all QML data, which includes plugins that are linked to all the extra libraries (for example site-packages/PySide6/Qt/qml/QtWebEngine/libqtwebenginequickplugin.so is linked against libQt6WebEngineCore.so.6).

Adding --exclude PySide6.QtQml to your PyInstaller command should prevent PySide6.QtQml from being pulled in and reduce the amount of collected Qt6 libraries.

We should probably modify our hook utilities to avoid adding the Py*.QtQml sub-package to hiddenimports even if there is a shared library dependency, as it makes no sense for a simple widgets-based application to pull in everything...

@rokm rokm removed the triage Please triage and relabel this issue label Dec 20, 2021
@xsun2001
Copy link
Author

So it is like a PySide6 "issue". Since pyinstaller is working as intended and the workaround you provided is great, I'm closing this issue. I would like to see the feature which enables pyinstaller to detect useless QtQml dependency to be integrated in the future. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants