hook-gi.repository.Gdk.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-2023, 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. from PyInstaller.utils.hooks.gi import GiModuleInfo
  12. from PyInstaller.utils.hooks import get_hook_config
  13. def hook(hook_api):
  14. # Use the Gdk version from hook config, if available. If not, try using Gtk version from hook config, so that we
  15. # collect Gdk and Gtk of the same version.
  16. module_versions = get_hook_config(hook_api, 'gi', 'module-versions')
  17. if module_versions:
  18. version = module_versions.get('Gdk')
  19. if not version:
  20. version = module_versions.get('Gtk', '3.0')
  21. else:
  22. version = '3.0'
  23. module_info = GiModuleInfo('Gdk', version)
  24. if not module_info.available:
  25. return
  26. binaries, datas, hiddenimports = module_info.collect_typelib_data()
  27. hiddenimports += ['gi._gi_cairo', 'gi.repository.cairo']
  28. hook_api.add_datas(datas)
  29. hook_api.add_binaries(binaries)
  30. hook_api.add_imports(*hiddenimports)