Skip to content

Commit 1d6f0e7

Browse files
committed
port python path changes added in flow's PR 3110
1 parent 24a3e5b commit 1d6f0e7

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

ci/src/test-python.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,35 @@ def get_all_python_plugins(manifest: dict) -> list:
8181
return [plugin for plugin in manifest if plugin["Language"].lower() == "python"]
8282

8383
def run_plugin(plugin_name: str, plugin_path: str, execute_path: str) -> bool:
84-
"""Run plugin and check output. Returns true if test successfull else false"""
84+
"""Run plugin and check output. Returns true if test successful else false"""
8585
os.chdir(plugin_path)
8686
default_settings = init_settings(plugin_name, plugin_path)
8787
args = json.dumps(
8888
{"method": "query", "parameters": [""], "Settings": default_settings}
8989
)
90-
full_args = ["python", "-S", Path(plugin_path, execute_path), args]
90+
9191
# Older Flox used environmental variable to locate Images directory
9292
os.environ["PYTHONPATH"] = str(USER_PATH.joinpath("PythonEmbeddable"))
93+
94+
# Compose the sys.path setup and runpy logic as Flow Launcher does
95+
sys_path_setup = (
96+
f"import sys; "
97+
f"sys.path.append(r'{plugin_path}'); "
98+
f"sys.path.append(r'{plugin_path}/lib'); "
99+
f"sys.path.append(r'{plugin_path}/lib/win32/lib'); "
100+
f"sys.path.append(r'{plugin_path}/lib/win32'); "
101+
f"sys.path.append(r'{plugin_path}/plugin'); "
102+
f"import runpy; "
103+
f"runpy.run_path(r'{Path(plugin_path, execute_path)}', None, '__main__')"
104+
)
105+
106+
full_args = [
107+
"python",
108+
"-S",
109+
"-c",
110+
sys_path_setup,
111+
args
112+
]
93113
print_section("Input", full_args)
94114
p = Popen(full_args, text=True, stdout=PIPE, stderr=PIPE)
95115
stdout, stderr = p.communicate()

0 commit comments

Comments
 (0)