hook-PyQt5.Qt.py 1.2 KB

1234567891011121314151617181920212223242526272829
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-2021, PyInstaller Development Team.
  3. #
  4. # Distributed under the terms of the GNU General Public License (version 2
  5. # or later) with exception for distributing the bootloader.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10. #-----------------------------------------------------------------------------
  11. # When PyQt5.Qt is imported it implies the import of all PyQt5 modules. See
  12. # http://pyqt.sourceforge.net/Docs/PyQt5/Qt.html.
  13. import os
  14. from PyInstaller.utils.hooks import get_module_file_attribute
  15. # Only do this if PyQt5 is found.
  16. mfi = get_module_file_attribute('PyQt5')
  17. if mfi:
  18. # Determine the name of all these modules by looking in the PyQt5 directory.
  19. hiddenimports = []
  20. for f in os.listdir(os.path.dirname(mfi)):
  21. root, ext = os.path.splitext(os.path.basename(f))
  22. if root.startswith('Qt') and root != 'Qt':
  23. # On Linux and OS X, PyQt 5.14.1 has a ``.abi3`` suffix on all library names. Remove it.
  24. if root.endswith('.abi3'):
  25. root = root[:-5]
  26. hiddenimports.append('PyQt5.' + root)