From 1ab1aceac687ea1581fc9158ad68620bfd2ea38f Mon Sep 17 00:00:00 2001 From: bwoodsend Date: Wed, 9 Sep 2020 10:18:43 +0100 Subject: [PATCH] Hooks: sysconfig: Remove obsolete pyconfig.h and makefile. As of Python 3.x, the config header and makefile are not longer used. And trying to include them causes build errors in pyenv/venv/equivalents. So applying this fixes 5018, fixes 4775, and closes 1545 (a cleanup issue). On Windows: The pyconfig.h data is hardcoded directly into sysconfig.py. And the makefile does not exist. On Unix: A Python extension module contains all the details. This module is a hidden import since 3.6 but is already marked as such in the hook. The functions to parse the files are still left over in sysconfig.py but they are not used anywhere. Should a user invoke the parser in a PyInstaller build, it will now fail but that API is not supposed to be public. Instead users should use get_config_var() which will always work (and is the recommended usage anyway). --- PyInstaller/hooks/hook-sysconfig.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/PyInstaller/hooks/hook-sysconfig.py b/PyInstaller/hooks/hook-sysconfig.py index c0ddcdf6de3..7544605faa7 100644 --- a/PyInstaller/hooks/hook-sysconfig.py +++ b/PyInstaller/hooks/hook-sysconfig.py @@ -9,27 +9,10 @@ # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception) #----------------------------------------------------------------------------- - -# The 'sysconfig' module requires Makefile and pyconfig.h files from -# Python installation. 'sysconfig' parses these files to get some -# information from them. -# TODO Verify that bundling Makefile and pyconfig.h is still required for Python 3. - import sysconfig -import os -from PyInstaller.utils.hooks import relpath_to_config_or_make from PyInstaller.compat import is_win -_CONFIG_H = sysconfig.get_config_h_filename() -_MAKEFILE = sysconfig.get_makefile_filename() - - -datas = [(_CONFIG_H, relpath_to_config_or_make(_CONFIG_H))] - -# The Makefile does not exist on all platforms, eg. on Windows -if os.path.exists(_MAKEFILE): - datas.append((_MAKEFILE, relpath_to_config_or_make(_MAKEFILE))) if not is_win and hasattr(sysconfig, '_get_sysconfigdata_name'): # Python 3.6 uses additional modules like @@ -38,3 +21,6 @@ # Note: Some versions of Anaconda backport this feature to before 3.6. # See issue #3105 hiddenimports = [sysconfig._get_sysconfigdata_name()] + + # Python 3.5 also keeps posix data in an extension module but it is + # imported using plain `import` so PyInstaller can detect it without help.