From 604d4a4d93dd1dd6c4727a0c7ed364e45ee83e35 Mon Sep 17 00:00:00 2001 From: jcm <6864788+jcm93@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:26:02 -0600 Subject: [PATCH] obs-scripting: Fix macOS Homebrew Python loading --- shared/obs-scripting/obs-scripting-python-import.c | 4 ++-- shared/obs-scripting/obs-scripting-python.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/obs-scripting/obs-scripting-python-import.c b/shared/obs-scripting/obs-scripting-python-import.c index 9981669cc32054..048c0326a9017b 100644 --- a/shared/obs-scripting/obs-scripting-python-import.c +++ b/shared/obs-scripting/obs-scripting-python-import.c @@ -35,7 +35,7 @@ #define PATH_MAX MAX_PATH #elif __APPLE__ #define VERSION_PATTERN "%d.%d" -#define FILE_PATTERN "Python.framework/Versions/Current/lib/libpython%s.dylib" +#define FILE_PATTERN "Python.framework/Versions/%s/lib/libpython%s.dylib" #endif #define PY_MAJOR_VERSION_MAX 3 @@ -71,7 +71,7 @@ bool import_python(const char *python_path, python_version_t *python_version) struct dstr temp; dstr_init(&temp); - dstr_printf(&temp, FILE_PATTERN, cur_version); + dstr_printf(&temp, FILE_PATTERN, cur_version, cur_version); int minor_version = PY_MINOR_VERSION_MAX; do { diff --git a/shared/obs-scripting/obs-scripting-python.c b/shared/obs-scripting/obs-scripting-python.c index c5a581cc8762ee..a650e841b65b39 100644 --- a/shared/obs-scripting/obs-scripting-python.c +++ b/shared/obs-scripting/obs-scripting-python.c @@ -1607,7 +1607,8 @@ bool obs_scripting_load_python(const char *python_path) if (python_path && *python_path) { #ifdef __APPLE__ char temp[PATH_MAX]; - snprintf(temp, sizeof(temp), "%s/Python.framework/Versions/Current", python_path); + snprintf(temp, sizeof(temp), "%s/Python.framework/Versions/%i.%i", python_path, python_version.major, + python_version.minor); os_utf8_to_wcs(temp, 0, home_path, PATH_MAX); Py_SetPythonHome(home_path); #else