hook-importlib_metadata.py 1.3 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_metadata is a library to access the metadata for a Python package.
  13. This functionality intends to replace most uses of pkg_resources entry point
  14. API and metadata API.
  15. """
  16. from PyInstaller.utils.hooks import copy_metadata
  17. # Normally, we should never need to use copy_metadata() in a hook since
  18. # metadata requirements detection is now automatic. However, that detection
  19. # first uses `PyiModuleGraph.get_code_using("importlib_metadata")` to find
  20. # files which `import importlib_metadata` and `get_code_using()`
  21. # intentionally excludes internal imports. This means that importlib_metadata
  22. # is not scanned for usages of importlib_metadata and therefore when
  23. # importlib_metadata uses its own API to get its version, this goes
  24. # undetected. Therefore, we must collect its metadata manually.
  25. datas = copy_metadata('importlib_metadata')