hook-sphinx.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-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. # ********************************************
  13. # hook-sphinx.py - Pyinstaller hook for Sphinx
  14. # ********************************************
  15. from PyInstaller.utils.hooks import collect_submodules, collect_data_files, \
  16. eval_statement
  17. hiddenimports = (
  18. # Per http://sphinx-doc.org/extensions.html#builtin-sphinx-extensions,
  19. # Sphinx extensions are all placed in ``sphinx.ext``. Include these.
  20. collect_submodules('sphinx.ext') +
  21. #
  22. # The following analysis applies to Sphinx v. 1.3.1, reported by "pip show
  23. # sphinx".
  24. #
  25. # From sphinx.application line 429:
  26. #
  27. # mod = __import__(extension, None, None, ['setup'])
  28. #
  29. # From sphinx.search line 228:
  30. #
  31. # lang_class = getattr(__import__(module, None, None, [classname]),
  32. # classname)
  33. #
  34. # From sphinx.search line 119:
  35. #
  36. # languages = {
  37. # 'da': 'sphinx.search.da.SearchDanish',
  38. # 'de': 'sphinx.search.de.SearchGerman',
  39. # 'en': SearchEnglish,
  40. #
  41. # So, we need all the languages in "sphinx.search".
  42. collect_submodules('sphinx.search') +
  43. collect_submodules('sphinx.websupport.search') +
  44. collect_submodules('sphinx.domains') +
  45. #
  46. # From sphinx.cmdline line 173:
  47. #
  48. # locale = __import__('locale') # due to submodule of the same name
  49. #
  50. # Add this module.
  51. ['locale'] +
  52. #
  53. # Sphinx relies on a number of built-in extensions that are dynamically
  54. # imported. Collect all those.
  55. list(eval_statement("""
  56. from sphinx.application import builtin_extensions
  57. print(builtin_extensions)
  58. """))
  59. )
  60. # Sphinx also relies on a number of data files in its directory hierarchy: for
  61. # example, *.html and *.conf files in ``sphinx.themes``, translation files in
  62. # ``sphinx.locale``, etc.
  63. datas = collect_data_files('sphinx') + collect_data_files('alabaster')