Skip to content

Commit

Permalink
Hooks: Include OpenGL fallback DLLs for PyQt5.
Browse files Browse the repository at this point in the history
Fixes #3458
  • Loading branch information
Siecje committed Jun 15, 2018
1 parent 56ee7e5 commit ecdf8b3
Showing 1 changed file with 40 additions and 13 deletions.
53 changes: 40 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,42 @@
'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 find_all_or_none(globs_to_include, num_files):
"""
globs_to_include is a list of file name globs
If the number of found files does not match num_files
then no files will be included.
"""
# TODO: This function is required because CI is failing to include libEGL
# The error in AppVeyor is:
# [2312] LOADER: Running pyi_lib_PyQt5-uic.py
# Failed to load libEGL (Access is denied.)
# More info: https://github.com/pyinstaller/pyinstaller/pull/3568
# Since the PyQt5 wheels do not include d3dcompiler_4?.dll, libEGL.dll and
# libGLESv2.dll will not be included for PyQt5 builds during CI.
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)
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) == num_files:
return to_include
return []


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

opengl_software_renderer = ['opengl32sw.dll']
binaries += find_all_or_none(opengl_software_renderer, 1)

# 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 += find_all_or_none(icu_files, 3)

0 comments on commit ecdf8b3

Please sign in to comment.