hook-hydra.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2022 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. from PyInstaller.compat import is_py310
  13. from PyInstaller.utils.hooks import collect_submodules, collect_data_files, is_module_satisfies
  14. # Collect core plugins.
  15. hiddenimports = collect_submodules('hydra._internal.core_plugins')
  16. # Hydra's plugin manager (`hydra.core.plugins.Plugins`) uses PEP-302 `find_module` / `load_module`, which has been
  17. # deprecated since python 3.4, and has been removed from PyInstaller's frozen importer in PyInstaller 5.8. For python
  18. # 3.10 and newer, they implemented new codepath that uses `find_spec`, but for earlier python versions, they opted to
  19. # keep using the old codepath.
  20. #
  21. # See: https://github.com/facebookresearch/hydra/pull/2531
  22. #
  23. # To work around the incompatibility with PyInstaller >= 5.8 when using python < 3.10, force collection of plugins as
  24. # source .py files. This way, they end up handled by python's built-in finder/importer instead of PyInstaller's
  25. # frozen importer.
  26. if not is_py310 and is_module_satisfies("PyInstaller >= 5.8"):
  27. module_collection_mode = {
  28. 'hydra._internal.core_plugins': 'py',
  29. 'hydra_plugins': 'py',
  30. }
  31. # Collect package's data files, such as default configuration files.
  32. datas = collect_data_files('hydra')