Skip to content

Commit

Permalink
Merge pull request #5055 from tuffnatty/fix/dynamicpython310plus
Browse files Browse the repository at this point in the history
ScriptingPython: fix building the dynamic binding against Python 3.10+ SDK
  • Loading branch information
pawelsalawa authored Sep 1, 2024
2 parents 430aa3d + 24f13ec commit 25560ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Plugins/ScriptingPython/dynamicpythonapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class DynamicPythonApi
#undef PyBytes_Check
#undef PyDict_Check
#undef PyFloat_Check
#undef PyObject_TypeCheck
#undef PyList_Check
#undef PyList_GET_SIZE
#undef PyLong_Check
#undef PySet_Check
#undef PyTuple_Check
Expand All @@ -135,16 +137,18 @@ class DynamicPythonApi
#define Py_INCREF Py_IncRef
#define Py_XDECREF Py_DecRef

#define PyBool_Check(x) (Py_TYPE((x)) == pPyBool_Type)
#define PyByteArray_Check(x) PyObject_TypeCheck((x), pPyByteArray_Type)
#define PyBytes_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_BYTES_SUBCLASS)
#define PyDict_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_DICT_SUBCLASS)
#define PyFloat_Check(x) PyObject_TypeCheck((x), pPyFloat_Type)
#define PyList_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_LIST_SUBCLASS)
#define PyLong_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_LONG_SUBCLASS)
#define PySet_Check(x) PyObject_TypeCheck((x), pPySet_Type)
#define PyTuple_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_TUPLE_SUBCLASS)
#define PyUnicode_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_UNICODE_SUBCLASS)
#define PyObject_TypeCheck(o, t) (Py_IS_TYPE((o), (t)) || PyType_IsSubtype(Py_TYPE((o)), (t)))
#define PyBool_Check(x) (Py_TYPE((x)) == pPyBool_Type)
#define PyByteArray_Check(x) PyObject_TypeCheck((x), pPyByteArray_Type)
#define PyBytes_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_BYTES_SUBCLASS)
#define PyDict_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_DICT_SUBCLASS)
#define PyFloat_Check(x) PyObject_TypeCheck((x), pPyFloat_Type)
#define PyList_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_LIST_SUBCLASS)
#define PyList_GET_SIZE(x) (_PyVarObject_CAST((x))->ob_size)
#define PyLong_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_LONG_SUBCLASS)
#define PySet_Check(x) PyObject_TypeCheck((x), pPySet_Type)
#define PyTuple_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_TUPLE_SUBCLASS)
#define PyUnicode_Check(x) PyType_HasFeature(Py_TYPE((x)), Py_TPFLAGS_UNICODE_SUBCLASS)

// There are a few constructs for which placing the stuff in the class scope is not enough
#ifndef DYNAMICPYTHONAPI_INTERNAL
Expand Down
2 changes: 2 additions & 0 deletions Plugins/ScriptingPython/scriptingpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,13 @@ static void globParts(QStringList& files, QList<QStringList> parts,
}
}

#if !defined(Q_OS_MACX) && defined(Q_OS_UNIX)
static inline QStringList dirNames(QStringList paths)
{
// Returns a path list where every last path component is removed
return paths.replaceInStrings(QRegularExpression("/?[^/]+/?$"), "");
}
#endif

QStringList ScriptingPython::discoverLibraries() const
{
Expand Down

0 comments on commit 25560ba

Please sign in to comment.