hook-narwhals.py 1.0 KB

12345678910111213141516171819202122
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2025 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. import sys
  13. from PyInstaller.utils.hooks import can_import_module, copy_metadata, is_module_satisfies
  14. # Starting with narwhals 1.35.0, we need to collect metadata for `typing_extensions` if the module is available.
  15. # The codepath that checks metadata for `typing_extensions` is not executed under python >= 3.13, so we can avoid
  16. # collection there.
  17. datas = []
  18. if sys.version_info < (3, 13): # PyInstaller.compat.is_py313 is available only in PyInstaller >= 6.10.0.
  19. if is_module_satisfies("narwhals >= 1.35.0") and can_import_module("typing_extensions"):
  20. datas += copy_metadata("typing_extensions")