Skip to content

Commit

Permalink
Hooks: sysconfig: Remove obsolete pyconfig.h and makefile.
Browse files Browse the repository at this point in the history
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, as well as fixes 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
 hidden 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).
  • Loading branch information
bwoodsend committed Oct 2, 2020
1 parent 81d7e6a commit e7ff0ec
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions PyInstaller/hooks/hook-sysconfig.py
Expand Up @@ -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
Expand All @@ -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.

0 comments on commit e7ff0ec

Please sign in to comment.