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-13 21:49:27 +02:00 • committed by Ryan Foster
commit ab21c7e5b0
3 changed files with 59 additions and 18 deletions

View file

@ -44,7 +44,6 @@
#endif
#if RUNTIME_LINK
#ifdef NO_REDEFS
#define PY_EXTERN
#else
@ -262,7 +261,7 @@ static inline void Import__Py_XDECREF(PyObject *op)
#undef Py_XDECREF
#define Py_XDECREF(op) Import__Py_XDECREF(_PyObject_CAST(op))
#endif
#endif // PY_VERSION_HEX >= 0x030800f0
#if PY_VERSION_HEX >= 0x030900b0
static inline int Import_PyType_HasFeature(PyTypeObject *type,
@ -271,8 +270,7 @@ static inline int Import_PyType_HasFeature(PyTypeObject *type,
return ((PyType_GetFlags(type) & feature) != 0);
}
#define PyType_HasFeature(t, f) Import_PyType_HasFeature(t, f)
#endif
#endif // PY_VERSION_HEX >= 0x030900b0
#endif
#endif
#endif // NO_REDEFS
#endif // RUNTIME_LINK