Skip to content

Commit 81b0750

Browse files
committed
fix(python-runner): compute full module path so relative imports work
1 parent b94b79a commit 81b0750

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/core/src/python/get-config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib.util
44
import os
55
import platform
6+
from pathlib import Path
67

78
def sendMessage(text):
89
'sends a Node IPC message to parent proccess'
@@ -35,7 +36,10 @@ async def run_python_module(file_path: str) -> None:
3536
raise ImportError(f"Could not load module from {file_path}")
3637

3738
module = importlib.util.module_from_spec(spec)
38-
module.__package__ = os.path.basename(module_dir)
39+
flows_dir = Path(file_path).parents[1]
40+
rel_parts = Path(file_path).relative_to(flows_dir).with_suffix("").parts
41+
module_name = flows_dir.name + "." + ".".join(rel_parts)
42+
module.__package__ = module_name.rsplit(".", 1)[0]
3943
spec.loader.exec_module(module)
4044

4145
if not hasattr(module, 'config'):

0 commit comments

Comments
 (0)