hook-gi.repository.GLib.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-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. """
  12. Import hook for the GLib library https://wiki.gnome.org/Projects/GLib introspected through
  13. PyGobject https://wiki.gnome.org/PyGObject via the GObject Introspection middleware layer
  14. https://wiki.gnome.org/Projects/GObjectIntrospection
  15. Tested with GLib 2.44.1, PyGObject 3.16.2, and GObject Introspection 1.44.0 on Mac OS 10.10 and
  16. GLib 2.42.2, PyGObject 3.14.0, and GObject Introspection 1.42 on Windows 7.
  17. """
  18. import glob
  19. import os
  20. from PyInstaller.compat import is_win
  21. from PyInstaller.utils.hooks import get_hook_config
  22. from PyInstaller.utils.hooks.gi import \
  23. collect_glib_share_files, collect_glib_translations, get_gi_libdir, get_gi_typelibs
  24. binaries, datas, hiddenimports = get_gi_typelibs('GLib', '2.0')
  25. def hook(hook_api):
  26. hook_datas = []
  27. lang_list = get_hook_config(hook_api, "gi", "languages")
  28. hook_datas += collect_glib_translations('glib20', lang_list)
  29. hook_api.add_datas(hook_datas)
  30. datas += collect_glib_share_files('glib-2.0', 'schemas')
  31. # On Windows, glib needs a spawn helper for g_spawn* API
  32. if is_win:
  33. libdir = get_gi_libdir('GLib', '2.0')
  34. pattern = os.path.join(libdir, 'gspawn-*-helper*.exe')
  35. for f in glob.glob(pattern):
  36. binaries.append((f, '.'))