summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-31 11:55:12 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-01 23:12:42 +0100
commit951942c3c284ec2c62e730e145688033190af9b2 (patch)
tree5336b54b688d78461d60181f1b028dd553ad2eb5
parent66cadd6be58bce5f7a56556cf92efd8159fb0b0e (diff)
downloadbitbake-951942c3c284ec2c62e730e145688033190af9b2.tar.gz
cooker: Restore sys.path and sys.modules between parses
When memory resident bitbake is active and we re-parse, the old module configuration is present which can lead to strange errors. Reset this when reparsing so the state is consistent. This fixes memory resident bitbake errors. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/cooker.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 1359d33f7..0d29aa03a 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -159,6 +159,9 @@ class BBCooker:
for f in featureSet:
self.featureset.setFeature(f)
+ self.orig_syspath = sys.path.copy()
+ self.orig_sysmodules = [*sys.modules]
+
self.configuration = bb.cookerdata.CookerConfiguration()
self.idleCallBackRegister = idleCallBackRegister
@@ -350,6 +353,11 @@ class BBCooker:
self.state = state.initial
self.caches_array = []
+ sys.path = self.orig_syspath.copy()
+ for mod in [*sys.modules]:
+ if mod not in self.orig_sysmodules:
+ del sys.modules[mod]
+
# Need to preserve BB_CONSOLELOG over resets
consolelog = None
if hasattr(self, "data"):