diff --git a/PyInstaller/hooks/hook-PyQt5.py b/PyInstaller/hooks/hook-PyQt5.py index 6742f68b4bc..52254613a85 100644 --- a/PyInstaller/hooks/hook-PyQt5.py +++ b/PyInstaller/hooks/hook-PyQt5.py @@ -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 @@ -18,16 +19,34 @@ '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')] +dlls_to_include = [ + # TODO: Uncomment when the standard PyQt5 wheel includes d3dcompiler_XX.dll + # 'libEGL.dll', 'libGLESv2.dll', 'd3dcompiler_??.dll', # ANGLE fallback + 'opengl32sw.dll', # OpenGL software renderer fallback + 'icudt??.dll', 'icuin??.dll', 'icuuc??.dll' # ICU files + # See "Deployment approach" section in ``PyInstaller/utils/hooks/qt.py`` +] +binaries = [] +for dll in dlls_to_include: + dll_path = os.path.join(pyqt5_library_info.location['BinariesPath'], dll) + dll_file_paths = glob.glob(dll_path) + # Only add files if they exist. + 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) + binaries.append((dll_file_path, dst_dll_path)) -# TODO: Include software rendering for OpenGL. See the "Deployment approach". However, because the standard PyQt5 wheel `doesn't include `_ ``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))] +# TODO: Once the PyQt5 wheels include d3dcompiler_??.dll remove this +# Only include ANGLE if all files are available, this prevents CI failure +angle_binaries = [] +for dll in ('libEGL.dll', 'libGLESv2.dll', 'd3dcompiler_??.dll'): + dll_path = os.path.join(pyqt5_library_info.location['BinariesPath'], dll) + dll_file_paths = glob.glob(dll_path) + # Only add files if they exist. + 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) + angle_binaries.append((dll_file_path, dst_dll_path)) + +if len(angle_binaries) == 3: + binaries += angle_binaries