diff --git a/domoticz-python310.patch b/domoticz-python310.patch new file mode 100644 index 0000000..6ed1623 --- /dev/null +++ b/domoticz-python310.patch @@ -0,0 +1,126 @@ +--- domoticz-2021.1/hardware/plugins/PluginManager.cpp.orig 2021-04-17 10:50:55.000000000 -0500 ++++ domoticz-2021.1/hardware/plugins/PluginManager.cpp 2021-12-16 10:37:07.768344269 -0600 +@@ -31,7 +31,7 @@ + #include "DelayedLink.h" + #include "../../main/EventsPythonModule.h" + +-#define MINIMUM_PYTHON_VERSION "3.4.0" ++#define MINIMUM_PYTHON_VERSION "3.10.0" + + #define ATTRIBUTE_VALUE(pElement, Name, Value) \ + { \ +@@ -110,6 +110,16 @@ + return false; + } + ++ Py_Initialize(); ++ ++ // Initialise threads. Python 3.7+ does this inside Py_Initialize so done here for compatibility ++ if (!PyEval_ThreadsInitialized()) ++ { ++ PyEval_InitThreads(); ++ } ++ ++ m_InitialPythonThread = PyEval_SaveThread(); ++ + // Set program name, this prevents it being set to 'python' + Py_SetProgramName(Py_GetProgramFullPath()); + +@@ -125,16 +135,6 @@ + return false; + } + +- Py_Initialize(); +- +- // Initialise threads. Python 3.7+ does this inside Py_Initialize so done here for compatibility +- if (!PyEval_ThreadsInitialized()) +- { +- PyEval_InitThreads(); +- } +- +- m_InitialPythonThread = PyEval_SaveThread(); +- + m_bEnabled = true; + _log.Log(LOG_STATUS, "PluginSystem: Started, Python version '%s'.", sVersion.c_str()); + } +--- domoticz-2021.1/hardware/plugins/Plugins.cpp.orig 2021-12-16 13:31:57.100559502 -0600 ++++ domoticz-2021.1/hardware/plugins/Plugins.cpp 2021-12-16 13:30:47.615287170 -0600 +@@ -1829,6 +1829,7 @@ + { + if (PyErr_Occurred()) + { ++ LogPythonException(sHandler); + PyErr_Clear(); + Log(LOG_NORM, "(%s) Python exception set prior to callback '%s'", m_Name.c_str(), sHandler.c_str()); + } +@@ -1837,7 +1837,11 @@ + if (pFunc && PyCallable_Check(pFunc)) + { + if (m_bDebug & PDM_QUEUE) +- Log(LOG_NORM, "(%s) Calling message handler '%s'.", m_Name.c_str(), sHandler.c_str()); ++ { ++ PyObject *reprParams = PyObject_Repr(pParams); ++ const char *sParams = PyUnicode_AsUTF8(reprParams); ++ Log(LOG_NORM, "(%s) Calling message handler '%s' with parameters '%s'.", m_Name.c_str(), sHandler.c_str(), sParams); ++ } + + PyErr_Clear(); + PyNewRef pReturnValue = PyObject_CallObject(pFunc, pParams); +--- domoticz-2021.1/hardware/plugins/DelayedLink.h.orig 2021-04-17 10:50:55.000000000 -0500 ++++ domoticz-2021.1/hardware/plugins/DelayedLink.h 2021-12-16 22:47:43.549253877 -0600 +@@ -9,6 +9,7 @@ + #ifdef WITH_THREAD + # undefine WITH_THREAD + #endif ++#define PY_SSIZE_T_CLEAN + #include + #include + #include +@@ -109,10 +110,10 @@ + DECLARE_PYTHON_SYMBOL(PyObject*, PyModule_Create2, struct PyModuleDef* COMMA int); + #endif + DECLARE_PYTHON_SYMBOL(int, PyModule_AddObject, PyObject* COMMA const char* COMMA PyObject*); +- DECLARE_PYTHON_SYMBOL(int, PyArg_ParseTuple, PyObject* COMMA const char* COMMA ...); +- DECLARE_PYTHON_SYMBOL(int, PyArg_ParseTupleAndKeywords, PyObject* COMMA PyObject* COMMA const char* COMMA char*[] COMMA ...); ++ DECLARE_PYTHON_SYMBOL(int, _PyArg_ParseTuple_SizeT, PyObject* COMMA const char* COMMA ...); ++ DECLARE_PYTHON_SYMBOL(int, _PyArg_ParseTupleAndKeywords_SizeT, PyObject* COMMA PyObject* COMMA const char* COMMA char*[] COMMA ...); + DECLARE_PYTHON_SYMBOL(PyObject*, PyUnicode_FromFormat, const char* COMMA ...); +- DECLARE_PYTHON_SYMBOL(PyObject*, Py_BuildValue, const char* COMMA ...); ++ DECLARE_PYTHON_SYMBOL(PyObject*, _Py_BuildValue_SizeT, const char* COMMA ...); + DECLARE_PYTHON_SYMBOL(void, PyMem_Free, void*); + DECLARE_PYTHON_SYMBOL(PyObject*, PyBool_FromLong, long); + DECLARE_PYTHON_SYMBOL(int, PyRun_SimpleStringFlags, const char* COMMA PyCompilerFlags*); +@@ -249,10 +250,10 @@ + RESOLVE_PYTHON_SYMBOL(PyModule_Create2); + #endif + RESOLVE_PYTHON_SYMBOL(PyModule_AddObject); +- RESOLVE_PYTHON_SYMBOL(PyArg_ParseTuple); +- RESOLVE_PYTHON_SYMBOL(PyArg_ParseTupleAndKeywords); ++ RESOLVE_PYTHON_SYMBOL(_PyArg_ParseTuple_SizeT); ++ RESOLVE_PYTHON_SYMBOL(_PyArg_ParseTupleAndKeywords_SizeT); + RESOLVE_PYTHON_SYMBOL(PyUnicode_FromFormat); +- RESOLVE_PYTHON_SYMBOL(Py_BuildValue); ++ RESOLVE_PYTHON_SYMBOL(_Py_BuildValue_SizeT); + RESOLVE_PYTHON_SYMBOL(PyMem_Free); + #ifdef _DEBUG + RESOLVE_PYTHON_SYMBOL(_Py_Dealloc); +@@ -460,8 +461,8 @@ + #define PyObject_IsInstance pythonLib->PyObject_IsInstance + #define PyObject_IsSubclass pythonLib->PyObject_IsSubclass + #define PyObject_Dir pythonLib->PyObject_Dir +-#define PyArg_ParseTuple pythonLib->PyArg_ParseTuple +-#define Py_BuildValue pythonLib->Py_BuildValue ++#define PyArg_ParseTuple pythonLib->_PyArg_ParseTuple_SizeT ++#define Py_BuildValue pythonLib->_Py_BuildValue_SizeT + #define PyMem_Free pythonLib->PyMem_Free + #ifdef _DEBUG + # define PyModule_Create2TraceRefs pythonLib->PyModule_Create2TraceRefs +@@ -469,7 +470,7 @@ + # define PyModule_Create2 pythonLib->PyModule_Create2 + #endif + #define PyModule_AddObject pythonLib->PyModule_AddObject +-#define PyArg_ParseTupleAndKeywords pythonLib->PyArg_ParseTupleAndKeywords ++#define PyArg_ParseTupleAndKeywords pythonLib->_PyArg_ParseTupleAndKeywords_SizeT + + #ifdef _DEBUG + # define _Py_Dealloc pythonLib->_Py_Dealloc diff --git a/domoticz.spec b/domoticz.spec index 4eda731..db56aa3 100644 --- a/domoticz.spec +++ b/domoticz.spec @@ -3,7 +3,7 @@ Name: domoticz Version: 2021.1 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Open source Home Automation System License: GPLv3+ and ASL 2.0 and Boost and BSD and MIT @@ -21,6 +21,8 @@ Patch1: %{name}-tinyxpath.patch Patch2: %{name}-python.patch # Python linking fix Patch3: %{name}-python-link.patch +# Python 3.10 support +Patch4: %{name}-python310.patch BuildRequires: boost-devel BuildRequires: cereal-devel @@ -95,6 +97,7 @@ any mobile device %patch1 -p1 -b.tinyxpath %patch2 -p1 -b.python %patch3 -p1 -b.python-link +%patch4 -p1 -b.python310 # Add support for future versions of Python by replacing hardcoded version with macro sed -i 's/-lpythonVER/-lpython%{python3_version}/' CMakeLists.txt rm -f hardware/openzwave/*.h @@ -230,6 +233,9 @@ usermod -G domoticz,dialout domoticz %changelog +* Thu Dec 16 2021 Michael Cronenworth - 2021.1-7 +- Add patch for Python 3.10 support + * Wed Nov 03 2021 Björn Esser - 2021.1-6 - Rebuild (jsoncpp)