obs-scripting: Add Python 3.11 support for Windows and macOS

This commit is contained in:
PatTheMav 2023-11-11 19:45:21 +01:00 • committed by Lain
commit 95cab7178e
3 changed files with 21 additions and 2 deletions

View file

@ -39,7 +39,7 @@
#endif
#define PY_MAJOR_VERSION_MAX 3
#define PY_MINOR_VERSION_MAX 11
#define PY_MINOR_VERSION_MAX 12
bool import_python(const char *python_path, python_version_t *python_version)
{

View file

@ -58,6 +58,7 @@ typedef struct python_version {
PY_EXTERN int (*Import_PyType_Ready)(PyTypeObject *);
PY_EXTERN PyObject *(*Import_PyObject_GenericGetAttr)(PyObject *, PyObject *);
PY_EXTERN void (*Import_PyType_Modified)(PyTypeObject *);
PY_EXTERN int (*Import_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *);
PY_EXTERN int (*Import_PyObject_IsTrue)(PyObject *);
PY_EXTERN void (*Import_Py_DecRef)(PyObject *);
PY_EXTERN void *(*Import_PyObject_Malloc)(size_t size);
@ -148,6 +149,8 @@ PY_EXTERN int (*Import_PyType_GetFlags)(PyTypeObject *o);
PY_EXTERN void (*Import__Py_Dealloc)(PyObject *obj);
#endif
PY_EXTERN PyTypeObject PyCFunction_Type;
extern bool import_python(const char *python_path,
python_version_t *python_version);
@ -155,6 +158,7 @@ extern bool import_python(const char *python_path,
#define PyType_Ready Import_PyType_Ready
#define PyType_GetFlags Import_PyType_GetFlags
#define PyType_Modified Import_PyType_Modified
#define PyType_IsSubtype Import_PyType_IsSubtype
#define PyObject_GenericGetAttr Import_PyObject_GenericGetAttr
#define PyObject_IsTrue Import_PyObject_IsTrue
#define Py_DecRef Import_Py_DecRef
@ -233,6 +237,7 @@ extern bool import_python(const char *python_path,
#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
#define _Py_Dealloc Import__Py_Dealloc
#endif
#if PY_VERSION_HEX >= 0x030800f0
static inline void Import__Py_DECREF(const char *filename, int lineno,
PyObject *op)
@ -264,6 +269,7 @@ static inline void Import__Py_XDECREF(PyObject *op)
#undef Py_XDECREF
#define Py_XDECREF(op) Import__Py_XDECREF(_PyObject_CAST(op))
#endif // PY_VERSION_HEX >= 0x030800f0
#if PY_VERSION_HEX >= 0x030900b0
static inline int Import_PyType_HasFeature(PyTypeObject *type,
unsigned long feature)
@ -273,5 +279,18 @@ static inline int Import_PyType_HasFeature(PyTypeObject *type,
#define PyType_HasFeature(t, f) Import_PyType_HasFeature(t, f)
#endif // PY_VERSION_HEX >= 0x030900b0
#if PY_VERSION_HEX >= 0x030a00b2
static inline int Import__PyObject_TypeCheck(PyObject *ob, PyTypeObject *type)
{
return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
}
#if PY_VERSION_HEX >= 0x030b00b3
#undef PyObject_TypeCheck
#define PyObject_TypeCheck(o, t) Import__PyObject_TypeCheck(o, t)
#else
#define _PyObject_TypeCheck(o, t) Import__PyObject_TypeCheck(o, t)
#endif // PY_VERSION_HEX >= 0x030b00b3
#endif // PY_VERSION_HEX >= 0x030a00b2
#endif // NO_REDEFS
#endif // RUNTIME_LINK

View file

@ -14,7 +14,7 @@ if(POLICY CMP0094)
cmake_policy(SET CMP0094 NEW)
endif()
find_package(Python 3.8...<3.11 REQUIRED Interpreter Development)
find_package(Python 3.8...<3.12 REQUIRED Interpreter Development)
find_package(SWIG 4 REQUIRED)
include(UseSWIG)