Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-scripting: Fix macOS Homebrew Python loading #11590

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shared/obs-scripting/obs-scripting-python-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion shared/obs-scripting/obs-scripting-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading