summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-14 10:56:15 +0100
committerGitHub <noreply@github.com>2022-01-14 10:56:15 +0100
commit9b3535a33a1dda541a3a39e7786b8428fadbff6c (patch)
treea91f06c64e7c66588cfcf84978b9edca92efa9b4 /SConstruct
parente529803ef941c015434d0366e6315f2b60bb6751 (diff)
parent9b781d24c02f1f94deb3ef29e81d5bd68a6b96c1 (diff)
Merge pull request #56766 from touilleMan/issue-56698-2
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct16
1 files changed, 16 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 03b409e09b..b8063589c6 100644
--- a/SConstruct
+++ b/SConstruct
@@ -10,6 +10,7 @@ import os
import pickle
import sys
import time
+from types import ModuleType
from collections import OrderedDict
from importlib.util import spec_from_file_location, module_from_spec
@@ -24,6 +25,21 @@ def _helper_module(name, path):
module = module_from_spec(spec)
spec.loader.exec_module(module)
sys.modules[name] = module
+ # Ensure the module's parents are in loaded to avoid loading the wrong parent
+ # when doing "import foo.bar" while only "foo.bar" as declared as helper module
+ child_module = module
+ parent_name = name
+ while True:
+ try:
+ parent_name, child_name = parent_name.rsplit(".", 1)
+ except ValueError:
+ break
+ try:
+ parent_module = sys.modules[parent_name]
+ except KeyError:
+ parent_module = ModuleType(parent_name)
+ sys.modules[parent_name] = parent_module
+ setattr(parent_module, child_name, child_module)
_helper_module("gles3_builders", "gles3_builders.py")