Commit 47b74ec2 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

Fix importlib usage for files with non .py extension

This is a fixup of 241c9484

See merge request !20
parent 3b03f468
......@@ -19,8 +19,10 @@ from .. import downloadunpacked
if sys.version_info >= (3, 5):
# See https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
import importlib.util
import importlib.machinery
def module_from_file_location(name, path):
spec = importlib.util.spec_from_file_location(name, path)
loader = importlib.machinery.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