From eeba583176b9faaa6fc6234d1b0bda9535e9683c Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 24 Feb 2023 16:13:53 +0100 Subject: [PATCH] dist: Support overriding list of built-in modules Useful when building for a platform that has a different set of built-in modules --- direct/src/dist/FreezeTool.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/direct/src/dist/FreezeTool.py b/direct/src/dist/FreezeTool.py index c978680680..33c49c273f 100644 --- a/direct/src/dist/FreezeTool.py +++ b/direct/src/dist/FreezeTool.py @@ -2378,6 +2378,8 @@ class PandaModuleFinder(modulefinder.ModuleFinder): :param debug: an integer indicating the level of verbosity """ + self.builtin_module_names = kw.pop('builtin_module_names', sys.builtin_module_names) + self.suffixes = kw.pop('suffixes', imp.get_suffixes()) self.optimize = kw.pop('optimize', -1) @@ -2702,11 +2704,12 @@ class PandaModuleFinder(modulefinder.ModuleFinder): if fullname in overrideModules: return (None, '', ('.py', 'r', imp.PY_SOURCE)) + # It's built into the interpreter. + if fullname in self.builtin_module_names: + return (None, None, ('', '', imp.C_BUILTIN)) + # If no search path is given, look for a built-in module. if path is None: - if name in sys.builtin_module_names: - return (None, None, ('', '', imp.C_BUILTIN)) - path = self.path if fullname == 'distutils' and hasattr(sys, 'real_prefix'):