From b3845806eb4b4389b8c9e31c39cbc9da4647e891 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 17 Sep 2024 07:43:26 -0700 Subject: [PATCH] Hack to try to find the last place that we need to modify sys.path to find the configs --- leapp/repository/__init__.py | 17 +++++++++++++++++ leapp/repository/actor_definition.py | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/leapp/repository/__init__.py b/leapp/repository/__init__.py index 98e6855a..5478758e 100644 --- a/leapp/repository/__init__.py +++ b/leapp/repository/__init__.py @@ -144,6 +144,23 @@ def load(self, resolve=True, stage=None, skip_actors_discovery=False): self.log.debug("Extending LEAPP_COMMON_FILES for common file paths") self._extend_environ_paths('LEAPP_COMMON_FILES', self.files) self.log.debug("Installing repository provided common libraries loader hook") + + try: + # libraries path: + with open("/tmp/debug.log", "a") as f: + f.write('%s' % self.libraries) + except Exception as e: + with open("/tmp/debug.log", "a") as f: + f.write("Exception reading self.libraries: %s" % e) + + try: + # configs path: + with open("/tmp/debug.log", "a") as f: + f.write('%s' % self.configs) + except Exception as e: + with open("/tmp/debug.log", "a") as f: + f.write("Exception reading self.configs: %s" % e) + sys.meta_path.append(LeappLibrariesFinder(module_prefix='leapp.libraries.common', paths=self.libraries)) sys.meta_path.append(LeappLibrariesFinder(module_prefix='leapp.workflows.api', paths=self.apis)) sys.meta_path.append(LeappLibrariesFinder(module_prefix='leapp.configs', paths=self.configs)) diff --git a/leapp/repository/actor_definition.py b/leapp/repository/actor_definition.py index bab23e22..a7a62d6f 100644 --- a/leapp/repository/actor_definition.py +++ b/leapp/repository/actor_definition.py @@ -314,6 +314,32 @@ def injected_context(self): module_prefix='leapp.libraries.actor', paths=[os.path.join(self._repo_dir, self.directory, x) for x in self.libraries])) + try: + # libraries path: + with open("/tmp/debug.log", "a") as f: + f.write('%s' % self.libraries) + except Exception as e: + with open("/tmp/debug.log", "a") as f: + f.write("Exception reading self.libraries: %s" % e) + + try: + # configs path: + with open("/tmp/debug.log", "a") as f: + f.write('%s' % self.configs) + except Exception as e: + with open("/tmp/debug.log", "a") as f: + f.write("Exception reading self.configs: %s" % e) + + sys.meta_path.append( + LeappLibrariesFinder( + module_prefix='leapp.configs', + paths=[os.path.join(self._repo_dir, self.directory, x) for x in self.configs])) + + sys.meta_path.append( + LeappLibrariesFinder( + module_prefix='leapp.configs.actor', + paths=[os.path.join(self._repo_dir, self.directory, x) for x in self.configs])) + previous_path = os.getcwd() os.chdir(os.path.join(self._repo_dir, self._directory)) try: