obs-scripting: Add support for multiple Python 3 versions

This changes the way obs-scripting looks for and loads an available
Python 3 library. It tries to find a best possible version (starting
with Python 3.10) down to and including Python 3.6 by existing file
naming conventions and loads the most recent variant it can find.

User specified search path is either a Python installation directory
(Windows), or a Framework directory containing `Python.framework`
(macOS). The dll or dylib names are composed automatically.
The Python home path is also composed automatically on macOS (where
it has to point inside the Framework directory).
This commit is contained in:
PatTheMav
2022-07-21 12:16:36 -04:00
committed by Ryan Foster
parent 47b3ff5e64
commit ab21c7e5b0
3 changed files with 59 additions and 18 deletions
+9
View File
@@ -1624,8 +1624,17 @@ bool obs_scripting_load_python(const char *python_path)
return false;
if (python_path && *python_path) {
#ifdef __APPLE__
char temp[PATH_MAX];
sprintf(temp, "%s/Python.framework/Versions/Current",
python_path);
os_utf8_to_wcs(temp, 0, home_path, PATH_MAX);
Py_SetPythonHome(home_path);
#else
os_utf8_to_wcs(python_path, 0, home_path, 1024);
Py_SetPythonHome(home_path);
#endif
#if 0
dstr_copy(&old_path, getenv("PATH"));
_putenv("PYTHONPATH=");