pyinstaller/pyinstaller-hooks-contrib

pyqtgraph hook no longer finds hidden imports since PyInstaller 5.2

Closed this issue · 0 comments

Hi,

When an application that uses pyqtgraph is frozen with PyInstaller 5.2, at runtime we get errors like:

  File "pyqtgraph\graphicsItems\ViewBox\ViewBoxMenu.py", line 6, in <module>
  File "importlib\__init__.py", line 126, in import_module
ModuleNotFoundError: No module named 'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5' 

The hook-pyqtgraph file contains code to dynamically load some files:

# pyqtgraph uses Qt-version-specific templates for the UI elements.
# There are templates for different versions of PySide and PyQt, e.g.
#
# - pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5
# - pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt6
# - pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyside2
# - pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyside6
# - pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5
# - pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt6
# - pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyside2
# - pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyside6
#
# To be future-proof, we include all of them via a filter in
# collect-submodules.
# Tested with pyqtgraph master branch (commit c1900aa).
hiddenimports = collect_submodules(
"pyqtgraph", filter=lambda name: "Template" in name)

I added some debugging code to it and noticed that hiddenimports is [], so digging the code history I could trace the problem to this commit:

pyinstaller/pyinstaller@17aa452

I will open a PR to fix this shortly. 👍