@@ -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
8383def 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