mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 13:08:50 +02:00
obs-scripting: Add Py 3.8+ C-API changes
Closes obsproject/obs-studio#3689
This commit is contained in:
parent
44ace7618f
commit
ecdc81ba0f
@ -143,6 +143,13 @@ bool import_python(const char *python_path)
|
|||||||
IMPORT_FUNC(_Py_NoneStruct);
|
IMPORT_FUNC(_Py_NoneStruct);
|
||||||
IMPORT_FUNC(PyTuple_New);
|
IMPORT_FUNC(PyTuple_New);
|
||||||
|
|
||||||
|
#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
|
||||||
|
IMPORT_FUNC(_Py_Dealloc);
|
||||||
|
#endif
|
||||||
|
#if PY_VERSION_HEX >= 0x030900b0
|
||||||
|
IMPORT_FUNC(PyType_GetFlags);
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef IMPORT_FUNC
|
#undef IMPORT_FUNC
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
|
58
deps/obs-scripting/obs-scripting-python-import.h
vendored
58
deps/obs-scripting/obs-scripting-python-import.h
vendored
@ -39,6 +39,14 @@
|
|||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_ATTRIBUTE_UNUSED) || defined(__MINGW32__)
|
||||||
|
#if !defined(UNUSED)
|
||||||
|
#define UNUSED __attribute__((unused))
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
@ -135,11 +143,23 @@ PY_EXTERN PyObject *(*Import_PyLong_FromUnsignedLongLong)(unsigned long long);
|
|||||||
PY_EXTERN int (*Import_PyArg_VaParse)(PyObject *, const char *, va_list);
|
PY_EXTERN int (*Import_PyArg_VaParse)(PyObject *, const char *, va_list);
|
||||||
PY_EXTERN PyObject(*Import__Py_NoneStruct);
|
PY_EXTERN PyObject(*Import__Py_NoneStruct);
|
||||||
PY_EXTERN PyObject *(*Import_PyTuple_New)(Py_ssize_t size);
|
PY_EXTERN PyObject *(*Import_PyTuple_New)(Py_ssize_t size);
|
||||||
|
#if PY_VERSION_HEX >= 0x030900b0
|
||||||
|
PY_EXTERN int (*Import_PyType_GetFlags)(PyTypeObject *o);
|
||||||
|
#endif
|
||||||
|
#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
|
||||||
|
PY_EXTERN void (*Import__Py_Dealloc)(PyObject *obj);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern bool import_python(const char *python_path);
|
extern bool import_python(const char *python_path);
|
||||||
|
|
||||||
#ifndef NO_REDEFS
|
#ifndef NO_REDEFS
|
||||||
#define PyType_Ready Import_PyType_Ready
|
#define PyType_Ready Import_PyType_Ready
|
||||||
|
#if PY_VERSION_HEX >= 0x030900b0
|
||||||
|
#define PyType_GetFlags Import_PyType_GetFlags
|
||||||
|
#endif
|
||||||
|
#if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
|
||||||
|
#define _Py_Dealloc Import__Py_Dealloc
|
||||||
|
#endif
|
||||||
#define PyObject_GenericGetAttr Import_PyObject_GenericGetAttr
|
#define PyObject_GenericGetAttr Import_PyObject_GenericGetAttr
|
||||||
#define PyObject_IsTrue Import_PyObject_IsTrue
|
#define PyObject_IsTrue Import_PyObject_IsTrue
|
||||||
#define Py_DecRef Import_Py_DecRef
|
#define Py_DecRef Import_Py_DecRef
|
||||||
@ -210,6 +230,44 @@ extern bool import_python(const char *python_path);
|
|||||||
#define PyArg_VaParse Import_PyArg_VaParse
|
#define PyArg_VaParse Import_PyArg_VaParse
|
||||||
#define _Py_NoneStruct (*Import__Py_NoneStruct)
|
#define _Py_NoneStruct (*Import__Py_NoneStruct)
|
||||||
#define PyTuple_New Import_PyTuple_New
|
#define PyTuple_New Import_PyTuple_New
|
||||||
|
#if PY_VERSION_HEX >= 0x030800f0
|
||||||
|
static inline void Import__Py_DECREF(const char *filename UNUSED,
|
||||||
|
int lineno UNUSED, PyObject *op)
|
||||||
|
{
|
||||||
|
if (--op->ob_refcnt != 0) {
|
||||||
|
#ifdef Py_REF_DEBUG
|
||||||
|
if (op->ob_refcnt < 0) {
|
||||||
|
_Py_NegativeRefcount(filename, lineno, op);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
_Py_Dealloc(op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef Py_DECREF
|
||||||
|
#define Py_DECREF(op) Import__Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
|
||||||
|
|
||||||
|
static inline void Import__Py_XDECREF(PyObject *op)
|
||||||
|
{
|
||||||
|
if (op != NULL) {
|
||||||
|
Py_DECREF(op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef Py_XDECREF
|
||||||
|
#define Py_XDECREF(op) Import__Py_XDECREF(_PyObject_CAST(op))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX >= 0x030900b0
|
||||||
|
static inline int Import_PyType_HasFeature(PyTypeObject *type,
|
||||||
|
unsigned long feature)
|
||||||
|
{
|
||||||
|
return ((PyType_GetFlags(type) & feature) != 0);
|
||||||
|
}
|
||||||
|
#define PyType_HasFeature(t, f) Import_PyType_HasFeature(t, f)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
4
deps/obs-scripting/obs-scripting-python.c
vendored
4
deps/obs-scripting/obs-scripting-python.c
vendored
@ -1654,7 +1654,9 @@ bool obs_scripting_load_python(const char *python_path)
|
|||||||
/* ---------------------------------------------- */
|
/* ---------------------------------------------- */
|
||||||
/* Load main interface module */
|
/* Load main interface module */
|
||||||
|
|
||||||
add_to_python_path(SCRIPT_DIR);
|
char *absolute_script_path = os_get_abs_path_ptr(SCRIPT_DIR);
|
||||||
|
add_to_python_path(absolute_script_path);
|
||||||
|
bfree(absolute_script_path);
|
||||||
|
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
char *exec_path = os_get_executable_path_ptr("");
|
char *exec_path = os_get_executable_path_ptr("");
|
||||||
|
Loading…
Reference in New Issue
Block a user