hook-distutils.py 1.3 KB

123456789101112131415161718192021222324252627282930
  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. """
  12. `distutils`-specific post-import hook.
  13. This hook freezes the external `Makefile` and `pyconfig.h` files bundled with
  14. the active Python interpreter, which the `distutils.sysconfig` module parses at
  15. runtime for platform-specific metadata.
  16. """
  17. from PyInstaller import compat
  18. # From Python 3.6 and later ``distutils.sysconfig`` takes on the same
  19. # behaviour as regular ``sysconfig`` of moving the config vars to a
  20. # module (see hook-sysconfig.py). It doesn't use a nice
  21. # `get module name` function like ``sysconfig`` does to help us
  22. # locate it but the module is the same file that ``sysconfig`` uses so
  23. # we can use the ``_get_sysconfigdata_name()`` from regular ``sysconfig``.
  24. import sysconfig
  25. if not compat.is_win and hasattr(sysconfig, '_get_sysconfigdata_name'):
  26. hiddenimports = [sysconfig._get_sysconfigdata_name()]