hook-sysconfig.py 1.5 KB

1234567891011121314151617181920212223242526272829
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-2023, 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. # see https://github.com/python/cpython/blob/3.9/Lib/sysconfig.py#L593
  13. # This will exclude `_osx_support`, `distutils`, `distutils.log` for sys.platform != 'darwin'
  14. if sys.platform != 'darwin':
  15. excludedimports = ["_osx_support"]
  16. # Python 3.6 uses additional modules like `_sysconfigdata_m_linux_x86_64-linux-gnu`, see
  17. # https://github.com/python/cpython/blob/3.6/Lib/sysconfig.py#L417
  18. # Note: Some versions of Anaconda backport this feature to before 3.6. See issue #3105.
  19. # Note: on Windows, python.org and Anaconda python provide _get_sysconfigdata_name, but calling it fails due to sys
  20. # module lacking abiflags attribute. It does work on MSYS2/MINGW python, where we need to collect corresponding file.
  21. try:
  22. import sysconfig
  23. hiddenimports = [sysconfig._get_sysconfigdata_name()]
  24. except AttributeError:
  25. # Either sysconfig has no attribute _get_sysconfigdata_name (i.e., the function does not exist), or this is Windows
  26. # and the _get_sysconfigdata_name() call failed due to missing sys.abiflags attribute.
  27. pass