hook-importlib_resources.py 1.2 KB

123456789101112131415161718192021222324252627282930
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2019-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. `importlib_resources` is a backport of the 3.9+ module `importlib.resources`
  13. """
  14. import os
  15. from PyInstaller.utils.hooks import get_module_file_attribute, is_module_satisfies
  16. if is_module_satisfies("importlib_resources >= 1.2.0"):
  17. # since 1.2.0 importlib.metadata is used which PyInstaller knows how to handle.
  18. pass
  19. else:
  20. # include the version.txt file, used to set __version__
  21. res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))
  22. datas = [
  23. (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),
  24. ]
  25. if is_module_satisfies("importlib_resources >= 1.3.1"):
  26. hiddenimports = ['importlib_resources.trees']