From b731e47eeb3e74d1a53ae88318063f0dd2cdd544 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 31 Mar 2022 11:55:12 +0100 Subject: bitbake: 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. (Bitbake rev: 951942c3c284ec2c62e730e145688033190af9b2) Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bitbake') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 1359d33f77..0d29aa03a0 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/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"): -- cgit v1.2.3-54-g00ecf