Search code examples
pythonopenglpyqtpyqt5pyinstaller

how to exclude opengl32sw.dll from pyqt5 library when using pyinstaller?


How to write the correct syntax for excluding opengl32sw.dll from pyqt5.

I have tried using exclude in the spec file but its not working.

excludes=['cryptography','PyQt5/bin/opengl32sw.dll']

Solution

  • The exclude command only works for Python modules and not for DLLs. I think an easy but dirty way in here is to create a virtualenv and manually deleting the DLLs you don't need.

    Another way which is more complicated is to locate the PyQt's hook file located in <Python_Path>\lib\site-packages\PyInstaller\utils\hooks\qt.py and disable the line which bundles opengl32sw.dll file:

    # Gather required Qt binaries, but only if all binaries in a group exist.
    def get_qt_binaries(qt_library_info):
        binaries = []
        angle_files = ['libEGL.dll', 'libGLESv2.dll', 'd3dcompiler_??.dll']
        binaries += find_all_or_none(angle_files, 3, qt_library_info)
    
        # comment the following two lines to exclude the `opengl32sw.dll`
        # opengl_software_renderer = ['opengl32sw.dll']
        # binaries += find_all_or_none(opengl_software_renderer, 1, qt_library_info)
    
        # 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, qt_library_info)
    
        return binaries