From 91dd802de682f17089f995dfb146516b23d0b36e Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 29 Jun 2022 16:07:48 +0200 Subject: [PATCH] dist: Include `_sysconfigdata` module properly Fixes #1326 --- direct/src/dist/FreezeTool.py | 12 ++++++++++++ makepanda/makewheel.py | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/direct/src/dist/FreezeTool.py b/direct/src/dist/FreezeTool.py index 1e5554afa9..6c9d382a5d 100644 --- a/direct/src/dist/FreezeTool.py +++ b/direct/src/dist/FreezeTool.py @@ -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: diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index 2e1b18ec45..fbcace6b56 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -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