From 178ec005bdfca44d3c19b5fd2dac65c6c1f46d52 Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 23 Mar 2022 08:44:06 +0100 Subject: [PATCH] obs-scripting: Add Resources to python path on macOS Also changes indentation of this block back to tabs to be consistent with the rest of the file Co-authored-by: PatTheMav --- deps/obs-scripting/obs-scripting-python.c | 35 +++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/deps/obs-scripting/obs-scripting-python.c b/deps/obs-scripting/obs-scripting-python.c index e1362baad..72edd9a95 100644 --- a/deps/obs-scripting/obs-scripting-python.c +++ b/deps/obs-scripting/obs-scripting-python.c @@ -1672,22 +1672,33 @@ bool obs_scripting_load_python(const char *python_path) /* Load main interface module */ #ifdef __APPLE__ - struct dstr bundle_path; - - dstr_init_move_array(&bundle_path, os_get_executable_path_ptr("")); - dstr_cat(&bundle_path, "../PlugIns"); - char *absolute_plugin_path = os_get_abs_path_ptr(bundle_path.array); - - if(absolute_plugin_path != NULL) { - add_to_python_path(absolute_plugin_path); - bfree(absolute_plugin_path); - } - dstr_free(&bundle_path); -#endif + struct dstr plugin_path; + struct dstr resource_path; + dstr_init_move_array(&plugin_path, os_get_executable_path_ptr("")); + dstr_init_copy(&resource_path, plugin_path.array); + dstr_cat(&plugin_path, "../PlugIns"); + dstr_cat(&resource_path, "../Resources"); + + char *absolute_plugin_path = os_get_abs_path_ptr(plugin_path.array); + char *absolute_resource_path = os_get_abs_path_ptr(resource_path.array); + + if(absolute_plugin_path != NULL) { + add_to_python_path(absolute_plugin_path); + bfree(absolute_plugin_path); + } + dstr_free(&plugin_path); + + if(absolute_resource_path != NULL) { + add_to_python_path(absolute_resource_path); + bfree(absolute_resource_path); + } + dstr_free(&resource_path); +#else char *absolute_script_path = os_get_abs_path_ptr(SCRIPT_DIR); add_to_python_path(absolute_script_path); bfree(absolute_script_path); +#endif py_obspython = PyImport_ImportModule("obspython"); bool success = !py_error();