From 5c801b04f2a899ef210ebced873b4b22424c264b 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 ++++++++++++++++++++++++++ leapp/utils/libraryfinder.py | 3 +++ 3 files changed, 46 insertions(+) diff --git a/leapp/repository/__init__.py b/leapp/repository/__init__.py index 98e6855a9..5478758e0 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 bab23e225..a7a62d6f0 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: diff --git a/leapp/utils/libraryfinder.py b/leapp/utils/libraryfinder.py index 59aeb1f3c..8ddea1f5c 100644 --- a/leapp/utils/libraryfinder.py +++ b/leapp/utils/libraryfinder.py @@ -32,3 +32,6 @@ def find_spec(self, fullname, path, target=None): # noqa; pylint: disable=unuse def find_module(self, fullname, path=None): """ Implementation for python <3.4 """ return self._implementation(method='find_module', fullname=fullname, path=path) + +class ConfigsSchemaFinder(LibraryFinder): + pass