hook-pkg_resources.py 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-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. from PyInstaller.utils.hooks import collect_submodules
  12. # pkg_resources keeps vendored modules in its _vendor subpackage, and does
  13. # sys.meta_path based import magic to expose them as pkg_resources.extern.*
  14. hiddenimports = collect_submodules('pkg_resources._vendor')
  15. # pkg_resources v45.0 dropped support for Python 2 and added this
  16. # module printing a warning. We could save some bytes if we would
  17. # replace this by a fake module.
  18. hiddenimports.append('pkg_resources.py2_warn')
  19. excludedimports = ['__main__']
  20. # Some more hidden imports. See:
  21. # https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/15#issuecomment-663699288
  22. # `packaging` can either be its own package, or embeded in
  23. # `pkg_resources._vendor.packaging`, or both.
  24. # Assume the worst and include both if present.
  25. hiddenimports += collect_submodules('packaging')
  26. hiddenimports += ['pkg_resources.markers']