hook-gi.repository.GtkSource.py 1.3 KB

12345678910111213141516171819202122232425262728293031
  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, collect_glib_share_files
  12. def hook(hook_api):
  13. module_info = GiModuleInfo('GtkSource', '3.0', hook_api=hook_api) # Pass hook_api to read version from hook config
  14. if not module_info.available:
  15. return
  16. binaries, datas, hiddenimports = module_info.collect_typelib_data()
  17. # Collect data files
  18. # The data directory name contains verbatim version, e.g.:
  19. # * GtkSourceView-3.0 -> /usr/share/gtksourceview-3.0
  20. # * GtkSourceView-4 -> /usr/share/gtksourceview-4
  21. # * GtkSourceView-5 -> /usr/share/gtksourceview-5
  22. datas += collect_glib_share_files(f'gtksourceview-{module_info.version}')
  23. hook_api.add_datas(datas)
  24. hook_api.add_binaries(binaries)
  25. hook_api.add_imports(*hiddenimports)