hook-astroid.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2020 PyInstaller Development Team.
  3. #
  4. # This file is distributed under the terms of the GNU General Public
  5. # License (version 2.0 or later).
  6. #
  7. # The full license is available in LICENSE, distributed with
  8. # this software.
  9. #
  10. # SPDX-License-Identifier: GPL-2.0-or-later
  11. # ------------------------------------------------------------------
  12. #
  13. # ***************************************************
  14. # hook-astriod.py - PyInstaller hook file for astriod
  15. # ***************************************************
  16. # The astriod package, in __pkginfo__.py, is version 1.1.1. Looking at its
  17. # source:
  18. #
  19. # From __init__.py, starting at line 111::
  20. #
  21. # BRAIN_MODULES_DIR = join(dirname(__file__), 'brain')
  22. # if BRAIN_MODULES_DIR not in sys.path:
  23. # # add it to the end of the list so user path take precedence
  24. # sys.path.append(BRAIN_MODULES_DIR)
  25. # # load modules in this directory
  26. # for module in listdir(BRAIN_MODULES_DIR):
  27. # if module.endswith('.py'):
  28. # __import__(module[:-3])
  29. #
  30. # So, we need all the Python source in the ``brain/`` subdirectory,
  31. # since this is run-time discovered and loaded. Therefore, these
  32. # files are all data files.
  33. from PyInstaller.utils.hooks import collect_data_files, collect_submodules, \
  34. is_module_or_submodule
  35. # Note that brain/ isn't a module (it lacks an __init__.py, so it can't be
  36. # referred to as astroid.brain; instead, locate it as package astriod,
  37. # subdirectory brain/.
  38. datas = collect_data_files('astroid', True, 'brain')
  39. # Update: in astroid v 1.4.1, the brain/ module import parts of astroid. Since
  40. # everything in brain/ is dynamically imported, these are hidden imports. For
  41. # simplicity, include everything in astroid. Exclude all the test/ subpackage
  42. # contents and the test_util module.
  43. hiddenimports = ['six'] + collect_submodules('astroid',
  44. lambda name: (not is_module_or_submodule(name, 'astroid.tests')) and
  45. (not name == 'test_util'))