Commit bfab6309 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

Fix importlib usage for files with non .py extension

This is a fixup of 241c9484
parent 3b03f468
......@@ -20,7 +20,8 @@ if sys.version_info >= (3, 5):
# See https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
import importlib.util
def module_from_file_location(name, path):
spec = importlib.util.spec_from_file_location(name, path)
loader = SourceFileLoader(name, path)
spec = importlib.util.spec_from_loader(name, loader)
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment