dist: Include _sysconfigdata module properly

Fixes #1326
This commit is contained in:
rdb 2022-06-29 16:07:48 +02:00
parent c325eabb9d
commit 91dd802de6
2 changed files with 27 additions and 0 deletions

View File

@ -1215,6 +1215,18 @@ class Freezer:
else:
self.__loadModule(self.ModuleDef(modname, implicit = True))
# Special case for sysconfig, which depends on a platform-specific
# sysconfigdata module on POSIX systems.
if 'sysconfig' in self.mf.modules:
if sys.version_info >= (3, 6):
if 'linux' in self.platform:
arch = self.platform.split('_', 1)[1]
self.__loadModule(self.ModuleDef('_sysconfigdata__linux_' + arch + '-linux-gnu', implicit=True))
elif 'mac' in self.platform:
self.__loadModule(self.ModuleDef('_sysconfigdata__darwin_darwin', implicit=True))
elif 'linux' in self.platform or 'mac' in self.platform:
self.__loadModule(self.ModuleDef('_sysconfigdata', implicit=True))
# Now, any new modules we found get added to the export list.
for origName in list(self.mf.modules.keys()):
if origName not in origToNewName:

View File

@ -687,6 +687,21 @@ __version__ = '{0}'
whl.write_file(target_path, source_path)
# Include the special sysconfigdata module.
if os.name == 'posix':
import sysconfig
if hasattr(sysconfig, '_get_sysconfigdata_name'):
modname = sysconfig._get_sysconfigdata_name() + '.py'
else:
modname = '_sysconfigdata.py'
for entry in sys.path:
source_path = os.path.join(entry, modname)
if os.path.isfile(source_path):
whl.write_file('deploy_libs/' + modname, source_path)
break
# Add plug-ins.
for lib in PLUGIN_LIBS:
plugin_name = 'lib' + lib