Skip to content
Permalink
Browse files

Hooks: Update PySide2 hooks to mirror PyQt5 approach.

  • Loading branch information...
bjones1 committed May 11, 2019
1 parent 32dfc5b commit 5b5791285332003940f4bc70c32bb0cf10a32917
Showing with 201 additions and 360 deletions.
  1. +2 −3 PyInstaller/hooks/hook-PySide2.QtCore.py
  2. +2 −16 PyInstaller/hooks/hook-PySide2.QtGui.py
  3. +2 −7 PyInstaller/hooks/hook-PySide2.QtHelp.py
  4. +2 −10 PyInstaller/hooks/hook-PySide2.QtMultimedia.py
  5. +19 −4 PyInstaller/hooks/hook-PySide2.QtNetwork.py
  6. +2 −3 PyInstaller/hooks/hook-PySide2.QtOpenGL.py
  7. +2 −6 PyInstaller/hooks/hook-PySide2.QtPrintSupport.py
  8. +26 −1 PyInstaller/hooks/hook-PySide2.QtQml.py
  9. +2 −107 PyInstaller/hooks/hook-PySide2.QtQuick.py
  10. +2 −6 PyInstaller/hooks/hook-PySide2.QtQuickWidgets.py
  11. +2 −5 PyInstaller/hooks/hook-PySide2.QtScript.py
  12. +2 −1 PyInstaller/hooks/hook-PySide2.QtSensors.py
  13. +2 −1 PyInstaller/hooks/hook-PySide2.QtSerialPort.py
  14. +2 −5 PyInstaller/hooks/hook-PySide2.QtSql.py
  15. +2 −3 PyInstaller/hooks/hook-PySide2.QtSvg.py
  16. +2 −1 PyInstaller/hooks/hook-PySide2.QtTest.py
  17. +2 −4 PyInstaller/hooks/hook-PySide2.QtWebKit.py
  18. +2 −7 PyInstaller/hooks/hook-PySide2.QtWebKitWidgets.py
  19. +2 −1 PyInstaller/hooks/hook-PySide2.QtWidgets.py
  20. +2 −1 PyInstaller/hooks/hook-PySide2.QtXml.py
  21. +11 −21 PyInstaller/hooks/hook-PySide2.py
  22. +0 −1 PyInstaller/loader/rthooks.dat
  23. +0 −1 PyInstaller/loader/rthooks/pyi_rth_pyqt5.py
  24. +6 −41 PyInstaller/loader/rthooks/pyi_rth_pyside2.py
  25. +0 −31 PyInstaller/loader/rthooks/pyi_rth_qml.py
  26. +89 −70 PyInstaller/utils/hooks/qt.py
  27. +1 −0 news/3655.bugfix.rst
  28. +1 −0 news/3689.bugfix.rst
  29. +1 −0 news/3724.bugfix.rst
  30. +1 −0 news/4040.bugfix.rst
  31. +1 −0 news/4103.bugfix.rst
  32. +1 −0 news/4136.bugfix.rst
  33. +1 −0 news/4175.bugfix.rst
  34. +1 −0 news/4177.bugfix.rst
  35. +1 −0 news/4198.bugfix.rst
  36. +1 −0 news/4206.bugfix.rst
  37. +1 −3 tests/functional/test_libraries.py
  38. +3 −0 tests/requirements-libraries.txt
@@ -6,7 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

from PyInstaller.utils.hooks import qt_plugins_binaries

binaries = qt_plugins_binaries('codecs', namespace='PySide2')
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,20 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

from PyInstaller.utils.hooks import qt_plugins_binaries
from PyInstaller.compat import is_linux

hiddenimports = ['PySide2.QtCore']

binaries = []
binaries.extend(qt_plugins_binaries('accessible', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('iconengines', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('imageformats', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('inputmethods', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('graphicssystems', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('platforms', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('styles', namespace='PySide2'))

if is_linux:
binaries.extend(qt_plugins_binaries('platformthemes', namespace='PySide2'))
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,11 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = [
'PySide2.QtCore',
'PySide2.QtGui',
'PySide2.QtSql',
'PySide2.QtNetwork',
'PySide2.QtWidgets',
]
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,14 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

from PyInstaller.utils.hooks import qt_plugins_binaries


# QtMultimedia tries to pull in QtNetwork
hiddenimports = ['PySide2.QtNetwork']

# QtMultimedia needs some plugins
binaries = []
binaries.extend(qt_plugins_binaries('audio', namespace='PySide2'))
binaries.extend(qt_plugins_binaries('mediaservice', namespace='PySide2'))
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,10 +6,25 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import os.path

from PyInstaller.utils.hooks import qt_plugins_binaries
from PyInstaller.utils.hooks import eval_statement
from PyInstaller.utils.hooks.qt import add_qt5_dependencies
from PyInstaller.compat import is_win
from PyInstaller.depend.bindepend import getfullnameof

hiddenimports = ['PySide2.QtCore']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)

# Network Bearer Management in qt 4.7+
binaries = qt_plugins_binaries('bearer', namespace='PySide2')
# Add libraries needed for SSL if these are available. See issue #3520, #4048.
if (is_win and eval_statement("""
from PySide2.QtNetwork import QSslSocket
print(QSslSocket.supportsSsl())""")):

rel_data_path = ['.']
binaries += [
# Per http://doc.qt.io/qt-5/ssl.html#enabling-and-disabling-ssl-support,
# the SSL libraries are dynamically loaded, implying they exist in
# the system path. Include these.
(getfullnameof('libeay32.dll'), os.path.join(*rel_data_path)),
(getfullnameof('ssleay32.dll'), os.path.join(*rel_data_path)),
]
@@ -6,7 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore',
'PySide2.QtWidgets',
'PySide2.QtGui']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,10 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

from PyInstaller.utils.hooks import qt_plugins_binaries

hiddenimports = ['PySide2.QtCore', 'PySide2.QtGui', 'PySide2.QtWidgets']

binaries = []
binaries.extend(qt_plugins_binaries('printsupport', namespace='PySide2'))
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,6 +6,31 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import os

from PyInstaller.utils import misc
from PyInstaller.utils.hooks.qt import pyside2_library_info, add_qt5_dependencies
from PyInstaller import log as logging

hiddenimports = ['PySide2.QtCore', 'PySide2.QtNetwork', 'PySide2.QtQuick']
logger = logging.getLogger(__name__)

hiddenimports, binaries, datas = add_qt5_dependencies(__file__)

qmldir = pyside2_library_info.location['Qml2ImportsPath']
# Not all PySide2 installs have QML files. In this case, ``qmldir`` is empty. In
# addition, the directory may not exist even if ``qmldir`` is not empty.
if not os.path.exists(qmldir):
logger.warning('Unable to find Qt5 QML files. QML files not packaged.')
else:
qml_rel_dir = ['PySide2', 'qml']
datas += [(qmldir, os.path.join(*qml_rel_dir))]
binaries += [
# Produce ``/path/to/Qt/Qml/path_to_qml_binary/qml_binary,
# PyQt5/Qt/Qml/path_to_qml_binary``. When Python 3.4 goes EOL (see
# PEP 448), this is better written as
# ``os.path.join(*qml_rel_dir,
# os.path.dirname(os.path.relpath(f, qmldir))))``.
(f, os.path.join(*(qml_rel_dir +
[os.path.dirname(os.path.relpath(f, qmldir))])))
for f in misc.dlls_in_subdirs(qmldir)
]
@@ -6,111 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

import os

from PyInstaller.utils import misc
from PyInstaller.utils.hooks import get_qmake_path, exec_command
from PyInstaller import log as logging

logger = logging.getLogger(__name__)


def qt5_qml_dir():
qmake = get_qmake_path('5')
if qmake is None:
qmldir = ''
logger.warning('Could not find qmake version 5.x, make sure PATH is '
'set correctly or try setting QT5DIR.')
else:
qmldir = exec_command(qmake, "-query", "QT_INSTALL_QML").strip()
if qmldir:
logger.error('Cannot find QT_INSTALL_QML directory, "qmake -query '
'QT_INSTALL_QML" returned nothing')
elif not os.path.exists(qmldir):
logger.error("Directory QT_INSTALL_QML: %s doesn't exist", qmldir)

# 'qmake -query' uses / as the path separator, even on Windows
qmldir = os.path.normpath(qmldir)
return qmldir


def qt5_qml_data(qmldir, directory):
"""
Return Qml library directory formatted for data.
"""
return os.path.join(qmldir, directory), os.path.join('qml', directory)


def qt5_qml_plugins_binaries(qmldir, directory):
"""
Return list of dynamic libraries formatted for mod.binaries.
"""
binaries = []

qt5_qml_plugin_dir = os.path.join(qmldir, directory)
files = misc.dlls_in_subdirs(qt5_qml_plugin_dir)

for f in files:
relpath = os.path.relpath(f, qmldir)
instdir, file = os.path.split(relpath)
instdir = os.path.join("qml", instdir)
logger.debug("qt5_qml_plugins_binaries installing %s in %s",
f, instdir)
binaries.append((f, instdir))
return binaries


def qt5_qml_plugins_datas(qmldir, directory):
"""
Return list of data files for ``mod.binaries. (qmldir, *.qmltypes)``
"""
datas = []

qt5_qml_plugin_dir = os.path.join(qmldir, directory)

files = []
for root, _dirs, _files in os.walk(qt5_qml_plugin_dir):
files.extend(misc.files_in_dir(root, ["qmldir", "*.qmltypes"]))

for f in files:
relpath = os.path.relpath(f, qmldir)
instdir, file = os.path.split(relpath)
instdir = os.path.join("qml", instdir)
logger.debug("qt5_qml_plugins_datas installing %s in %s",
f, instdir)
datas.append((f, instdir))
return datas


hiddenimports = ['PySide2.QtCore',
'PySide2.QtQml',
'PySide2.QtGui',
'PySide2.QtNetwork'
]

# TODO: we should parse the Qml files to see what we need to import.
dirs = ['Qt',
# 'QtAudioEngine',
# 'QtGraphicalEffects',
# 'QtMultiMedia',
'QtQml',
'QtQuick',
'QtQuick.2',
# 'QtSensors',
# 'QtTest'
]

qmldir = qt5_qml_dir()

# Add base qml directories
datas = [qt5_qml_data(qmldir, dir) for dir in dirs]

# Add qmldir and *.qmltypes files
for dir in dirs:
datas.extend(qt5_qml_plugins_datas(qmldir, dir))

# Add binaries
binaries = []
for dir in dirs:
binaries.extend(qt5_qml_plugins_binaries(qmldir, dir))
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,10 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore',
'PySide2.QtQuick',
'PySide2.QtQml',
'PySide2.QtGui',
'PySide2.QtNetwork'
]
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,9 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

from PyInstaller.utils.hooks import qt_plugins_binaries

hiddenimports = ['PySide2.QtCore']

binaries = qt_plugins_binaries('script', namespace='PySide2')
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,5 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,5 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,9 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

from PyInstaller.utils.hooks import qt_plugins_binaries

hiddenimports = ['PySide2.QtCore']

binaries = qt_plugins_binaries('sqldrivers', namespace='PySide2')
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,7 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore',
'PySide2.QtWidgets',
'PySide2.QtGui']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,5 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,8 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore',
'PySide2.QtGui',
'PySide2.QtNetwork'
]
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,11 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

# Shorten list of hidden imports to what PySide2.QtWebKitWidgets actually
# does link to. It does not need Qml, QSql, or QtQuick.
hiddenimports = ['PySide2.QtCore',
'PySide2.QtGui',
'PySide2.QtNetwork',
'PySide2.QtWebKit'
]
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -6,5 +6,6 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports = ['PySide2.QtCore', 'PySide2.QtGui']
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
@@ -7,5 +7,6 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

hiddenimports = ['PySide2.QtCore']
from PyInstaller.utils.hooks.qt import add_qt5_dependencies

hiddenimports, binaries, datas = add_qt5_dependencies(__file__)

0 comments on commit 5b57912

Please sign in to comment.
You can’t perform that action at this time.