Skip to content

Commit

Permalink
Hooks: Include OpenGL Fallback DLLs for PyQt5. Fixes issue pyinstalle…
Browse files Browse the repository at this point in the history
  • Loading branch information
Siecje committed Jun 13, 2018
1 parent 56ee7e5 commit 42c9716
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions PyInstaller/hooks/hook-PyQt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import glob
import os

from PyInstaller.utils.hooks import pyqt5_library_info, collect_system_data_files
Expand All @@ -18,16 +19,35 @@
'PyQt5')
if os.path.basename(x[0]) == 'qt.conf']

# Include ICU files, if they exist. See the "Deployment approach" section in
# ``PyInstaller/utils/hooks/qt.py``.
[(os.path.join(pyqt5_library_info.location['BinariesPath'], dll),
os.path.join('PyQt5', 'Qt', 'bin', dll))
for dll in ('icudt??.dll', 'icuin??.dll', 'icuuc??.dll')]

# TODO: Include software rendering for OpenGL. See the "Deployment approach". However, because the standard PyQt5 wheel `doesn't include <https://www.riverbankcomputing.com/pipermail/pyqt/2018-June/040387.html>`_ ``d3dcompiler_XX.dll``, this produces failures. When the wheel is updated, this code can be uncommented.
##binaries = []
##for dll in ('libEGL.dll', 'libGLESv2.dll', 'd3dcompiler_??.dll', 'opengl32sw.dll'):
## dll_path = os.path.join(pyqt5_library_info.location['BinariesPath'], dll)
## # Only add files if they exist.
## if glob(dll_path):
## binaries += [(dll_path, os.path.join('PyQt5', 'Qt', 'bin', dll))]

def include_all_or_none(globs_to_include):
"""
globs_to_include is a list of file name globs
Each glob can only match one file.
Every file must be available in order for any in the provided list to be
included.
"""
to_include = []
for dll in globs_to_include:
dll_path = os.path.join(pyqt5_library_info.location['BinariesPath'],
dll)
dll_file_paths = glob.glob(dll_path)[:1]
for dll_file_path in dll_file_paths:
file_name = os.path.basename(dll_file_path)
dst_dll_path = os.path.join('PyQt5', 'Qt', 'bin', file_name)
to_include.append((dll_file_path, dst_dll_path))
if len(to_include) == len(globs_to_include):
return to_include
return []

binaries = []
angle_files = ['libEGL.dll', 'libGLESv2.dll', 'd3dcompiler_??.dll']
binaries += include_all_or_none(angle_files)

opengl_software_renderer = ['opengl32sw.dll']
binaries += include_all_or_none(opengl_software_renderer)

# Include ICU files, if they exist.
# See the "Deployment approach" section in ``PyInstaller/utils/hooks/qt.py``.
icu_files = ['icudt??.dll', 'icuin??.dll', 'icuuc??.dll']
binaries += include_all_or_none(angle_files)

0 comments on commit 42c9716

Please sign in to comment.