Skip to content

Commit

Permalink
refactor: replace deprecated load_module
Browse files Browse the repository at this point in the history
  • Loading branch information
kuwv authored and bitprophet committed Apr 28, 2023
1 parent d99f7a2 commit 3eca6af
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions invoke/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ def load(self, name: Optional[str] = None) -> Tuple[ModuleType, str]:
spec = self.find(name)
if spec and spec.loader and spec.origin:
path = spec.origin
# Ensure containing directory is on sys.path in case the module
# being imported is trying to load local-to-it names.
if os.path.isfile(spec.origin):
path = os.path.dirname(spec.origin)
if path not in sys.path:
sys.path.insert(0, path)
# Actual import
module = module_from_spec(spec)
spec.loader.exec_module(module)
return module, os.path.dirname(spec.origin)
Expand Down

0 comments on commit 3eca6af

Please sign in to comment.