Skip to content

Commit

Permalink
Hack to try to find the last place that we need to modify sys.path to…
Browse files Browse the repository at this point in the history
… find the configs
  • Loading branch information
abadger committed Sep 17, 2024
1 parent ae7987e commit 5c801b0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
17 changes: 17 additions & 0 deletions leapp/repository/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
26 changes: 26 additions & 0 deletions leapp/repository/actor_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions leapp/utils/libraryfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5c801b0

Please sign in to comment.