hook-_tkinter.py 1.3 KB

1234567891011121314151617181920212223242526272829
  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. import sys
  12. from PyInstaller import compat
  13. from PyInstaller.utils.hooks import logger
  14. from PyInstaller.utils.hooks.tcl_tk import collect_tcl_tk_files
  15. def hook(hook_api):
  16. # Use a hook-function to get the module's attr:`__file__` easily.
  17. """
  18. Freeze all external Tcl/Tk data files if this is a supported platform *or* log a non-fatal error otherwise.
  19. """
  20. if compat.is_win or compat.is_darwin or compat.is_unix:
  21. # collect_tcl_tk_files() returns a Tree, so we need to store it into `hook_api.datas` in order to prevent
  22. # `building.imphook.format_binaries_and_datas` from crashing with "too many values to unpack".
  23. hook_api.add_datas(collect_tcl_tk_files(hook_api.__file__))
  24. else:
  25. logger.error("... skipping Tcl/Tk handling on unsupported platform %s", sys.platform)