Prepend the script's path, not curdir - same as python interpreter does
@@ -14,11 +14,10 @@ Currently, two loading modes are supported, both are equivalent to Python CLI:
Multiple files/modules can be specified. They will be loaded in the order.
"""
-import sys
import importlib
import importlib.util
import os.path
-
+import sys
def preload(paths, modules):
@@ -27,7 +26,7 @@ def preload(paths, modules):
"""
for path in paths:
- sys.path.append(os.path.abspath(os.path.curdir))
+ sys.path.insert(0, os.path.abspath(os.path.dirname(path)))
name, _ = os.path.splitext(os.path.basename(path))
spec = importlib.util.spec_from_file_location(name, path)
module = importlib.util.module_from_spec(spec)
