hook-importlib_metadata.py 1.3 KB

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