#----------------------------------------------------------------------------- """ `distutils`-specific post-import hook. This hook freezes the external `Makefile` and `pyconfig.h` files bundled with the active Python interpreter, which the `distutils.sysconfig` module parses at runtime for platform-specific metadata. """ # TODO Verify that bundling Makefile and pyconfig.h is still required for Python 3. import os import sysconfig from PyInstaller.utils.hooks import relpath_to_config_or_make _CONFIG_H = sysconfig.get_config_h_filename() if hasattr(sysconfig, 'get_makefile_filename'): # sysconfig.get_makefile_filename is missing in Python < 2.7.9 _MAKEFILE = sysconfig.get_makefile_filename() else: _MAKEFILE = sysconfig._get_makefile_filename() # Data files in PyInstaller hook format. 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)))
# coding=utf-8 # 使用sysconfig import sysconfig print sysconfig.get_config_var('Py_ENABLE_SHARED') print sysconfig.get_config_var('LIBDIR') print sysconfig.get_config_vars('AR', "CXX") print sysconfig.get_scheme_names() print sysconfig.get_path_names() print sysconfig.get_python_version() print sysconfig.get_platform() # return true if current python installation was built from source print sysconfig.is_python_build() print sysconfig.get_config_h_filename() print sysconfig._get_makefile_filename()
def test_get_makefile_filename(self): makefile = sysconfig.get_makefile_filename() self.assertTrue(os.path.isfile(makefile), makefile) # Issue 22199 self.assertEqual(sysconfig._get_makefile_filename(), makefile)