Skip to content

Commit

Permalink
draft: Fix FileFinder error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rezney committed Apr 12, 2024
1 parent 7f772d6 commit 143d268
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion leapp/repository/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pkgutil
import sys
import importlib.util

from leapp.exceptions import RepoItemPathDoesNotExistError, UnsupportedDefinitionKindError
from leapp.models import get_models, resolve_model_references
Expand Down Expand Up @@ -166,7 +167,10 @@ def _load_modules(self, modules, prefix):
directories = [os.path.join(self._repo_dir, os.path.dirname(module)) for module in modules]
prefix = prefix + '.' if not prefix.endswith('.') else prefix
for importer, name, ispkg in pkgutil.iter_modules(directories, prefix=prefix):
importer.find_module(name).load_module(name)
spec = importer.find_spec(name)
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)

def serialize(self):
"""
Expand Down
6 changes: 5 additions & 1 deletion leapp/repository/actor_definition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import importlib.util
import linecache
import logging
import os
Expand Down Expand Up @@ -193,7 +194,10 @@ def load(self):
path = os.path.abspath(os.path.join(self._repo_dir, self.directory))
for importer, name, is_pkg in pkgutil.iter_modules((path,)):
if not is_pkg:
self._module = importer.find_module(name).load_module(name)
spec = importer.find_spec(name)
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
break

def discover(self):
Expand Down

0 comments on commit 143d268

Please sign in to comment.