forked from pool/FreeCAD
Accepting request 670582 from home:wolfi323:branches:KDE:Extra
- Add upstream patches to fix build with python 3.7: * get-rid-of-private-function-_PyImport_FixupBuiltin-for-__FreeCADBase__-module.patch * get-rid-of-private-function-_PyImport_FixupBuiltin-for-FreeCAD-and-FreeCADGui-modules.patch I haven't actually tested it with python 3.7 (it builds fine though), but it still works with 3.6.5 on my Leap 15.0 system. OBS-URL: https://build.opensuse.org/request/show/670582 OBS-URL: https://build.opensuse.org/package/show/science/FreeCAD?expand=0&rev=55
This commit is contained in:
parent
46820785de
commit
82dda12707
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 1 09:42:55 UTC 2019 - wbauer@tmo.at
|
||||
|
||||
- Add upstream patches to fix build with python 3.7:
|
||||
* get-rid-of-private-function-_PyImport_FixupBuiltin-for-__FreeCADBase__-module.patch
|
||||
* get-rid-of-private-function-_PyImport_FixupBuiltin-for-FreeCAD-and-FreeCADGui-modules.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 5 14:50:23 UTC 2018 - Jan Engelhardt <jengelh@inai.de>
|
||||
|
||||
|
@ -37,6 +37,10 @@ Patch2: 0001-find-openmpi2-include-files.patch
|
||||
Patch3: fix-draft-module-with-python3.patch
|
||||
# PATCH-FIX-UPSTREAM -- fix-build-with-Qt5_11.diff
|
||||
Patch4: fix-build-with-Qt5_11.diff
|
||||
# PATCH-FIX-UPSTREAM -- https://github.com/FreeCAD/FreeCAD/commit/8c08635d3
|
||||
Patch5: get-rid-of-private-function-_PyImport_FixupBuiltin-for-__FreeCADBase__-module.patch
|
||||
# PATCH-FIX-UPSTREAM -- https://github.com/FreeCAD/FreeCAD/commit/b79e1bfee
|
||||
Patch6: get-rid-of-private-function-_PyImport_FixupBuiltin-for-FreeCAD-and-FreeCADGui-modules.patch
|
||||
BuildRequires: Coin-devel
|
||||
#BuildRequires: SoQt-devel
|
||||
#BuildRequires: libmed-devel # needed for FEM module, but requires older hdf5 lib
|
||||
|
@ -0,0 +1,121 @@
|
||||
From b79e1bfee45d003e5ba646d828faca5d673f3e9b Mon Sep 17 00:00:00 2001
|
||||
From: wmayer <wmayer@users.sourceforge.net>
|
||||
Date: Sat, 1 Sep 2018 19:57:15 +0200
|
||||
Subject: [PATCH] get rid of private function _PyImport_FixupBuiltin for
|
||||
FreeCAD and FreeCADGui modules
|
||||
|
||||
---
|
||||
src/App/Application.cpp | 38 ++++++++++++++++++++++++++++++--------
|
||||
src/Gui/Application.cpp | 6 ++++--
|
||||
src/Main/MainPy.cpp | 4 +++-
|
||||
3 files changed, 37 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/App/Application.cpp b/src/App/Application.cpp
|
||||
index 82270e3eea0..0895a8c83ac 100644
|
||||
--- a/src/App/Application.cpp
|
||||
+++ b/src/App/Application.cpp
|
||||
@@ -226,6 +226,21 @@ init_freecad_base_module(void)
|
||||
};
|
||||
return PyModule_Create(&BaseModuleDef);
|
||||
}
|
||||
+
|
||||
+// Set in inside Application
|
||||
+static PyMethodDef* __AppMethods = nullptr;
|
||||
+
|
||||
+PyMODINIT_FUNC
|
||||
+init_freecad_module(void)
|
||||
+{
|
||||
+ static struct PyModuleDef FreeCADModuleDef = {
|
||||
+ PyModuleDef_HEAD_INIT,
|
||||
+ "FreeCAD", FreeCAD_doc, -1,
|
||||
+ __AppMethods,
|
||||
+ NULL, NULL, NULL, NULL
|
||||
+ };
|
||||
+ return PyModule_Create(&FreeCADModuleDef);
|
||||
+}
|
||||
#endif
|
||||
|
||||
Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
@@ -239,14 +254,15 @@ Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
// setting up Python binding
|
||||
Base::PyGILStateLocker lock;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
- static struct PyModuleDef FreeCADModuleDef = {
|
||||
- PyModuleDef_HEAD_INIT,
|
||||
- "FreeCAD", FreeCAD_doc, -1,
|
||||
- Application::Methods,
|
||||
- NULL, NULL, NULL, NULL
|
||||
- };
|
||||
- PyObject* pAppModule = PyModule_Create(&FreeCADModuleDef);
|
||||
- _PyImport_FixupBuiltin(pAppModule, "FreeCAD");
|
||||
+ PyObject* modules = PyImport_GetModuleDict();
|
||||
+
|
||||
+ __AppMethods = Application::Methods;
|
||||
+ PyObject* pAppModule = PyImport_ImportModule ("FreeCAD");
|
||||
+ if (!pAppModule) {
|
||||
+ PyErr_Clear();
|
||||
+ pAppModule = init_freecad_module();
|
||||
+ PyDict_SetItemString(modules, "FreeCAD", pAppModule);
|
||||
+ }
|
||||
#else
|
||||
PyObject* pAppModule = Py_InitModule3("FreeCAD", Application::Methods, FreeCAD_doc);
|
||||
#endif
|
||||
@@ -282,6 +298,11 @@ Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyObject* pBaseModule = PyImport_ImportModule ("__FreeCADBase__");
|
||||
+ if (!pBaseModule) {
|
||||
+ PyErr_Clear();
|
||||
+ pBaseModule = init_freecad_base_module();
|
||||
+ PyDict_SetItemString(modules, "__FreeCADBase__", pBaseModule);
|
||||
+ }
|
||||
#else
|
||||
PyObject* pBaseModule = Py_InitModule3("__FreeCADBase__", NULL, Base_doc);
|
||||
#endif
|
||||
@@ -1427,6 +1448,7 @@ void Application::initConfig(int argc, char ** argv)
|
||||
|
||||
// init python
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
+ PyImport_AppendInittab ("FreeCAD", init_freecad_module);
|
||||
PyImport_AppendInittab ("__FreeCADBase__", init_freecad_base_module);
|
||||
#endif
|
||||
mConfig["PythonSearchPath"] = Interpreter().init(argc,argv);
|
||||
diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp
|
||||
index 33ddde2b4c6..8715c8d6e52 100644
|
||||
--- a/src/Gui/Application.cpp
|
||||
+++ b/src/Gui/Application.cpp
|
||||
@@ -345,7 +345,8 @@ Application::Application(bool GUIenabled)
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
// if this returns a valid pointer then the 'FreeCADGui' Python module was loaded,
|
||||
// otherwise the executable was launched
|
||||
- PyObject *module = PyImport_AddModule("FreeCADGui");
|
||||
+ PyObject* modules = PyImport_GetModuleDict();
|
||||
+ PyObject* module = PyDict_GetItemString(modules, "FreeCADGui");
|
||||
if (!module) {
|
||||
static struct PyModuleDef FreeCADGuiModuleDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
@@ -354,7 +355,8 @@ Application::Application(bool GUIenabled)
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
module = PyModule_Create(&FreeCADGuiModuleDef);
|
||||
- _PyImport_FixupBuiltin(module, "FreeCADGui");
|
||||
+
|
||||
+ PyDict_SetItemString(modules, "FreeCADGui", module);
|
||||
}
|
||||
else {
|
||||
// extend the method list
|
||||
diff --git a/src/Main/MainPy.cpp b/src/Main/MainPy.cpp
|
||||
index 061740903c0..58b86fa7991 100644
|
||||
--- a/src/Main/MainPy.cpp
|
||||
+++ b/src/Main/MainPy.cpp
|
||||
@@ -225,7 +225,9 @@ PyMOD_INIT_FUNC(FreeCAD)
|
||||
free(argv);
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
- PyObject* module = _PyImport_FindBuiltin("FreeCAD");
|
||||
+ //PyObject* module = _PyImport_FindBuiltin("FreeCAD");
|
||||
+ PyObject* modules = PyImport_GetModuleDict();
|
||||
+ PyObject* module = PyDict_GetItemString(modules, "FreeCAD");
|
||||
if (!module) {
|
||||
PyErr_SetString(PyExc_ImportError, "Failed to load FreeCAD module!");
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
From 8c08635d301c3418810e5c8984bdb9f2c17cb9dc Mon Sep 17 00:00:00 2001
|
||||
From: wmayer <wmayer@users.sourceforge.net>
|
||||
Date: Sat, 1 Sep 2018 16:26:18 +0200
|
||||
Subject: [PATCH] get rid of private function _PyImport_FixupBuiltin for
|
||||
__FreeCADBase__ module
|
||||
|
||||
---
|
||||
src/App/Application.cpp | 27 ++++++++++++++++++++-------
|
||||
1 file changed, 20 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/App/Application.cpp b/src/App/Application.cpp
|
||||
index f719cd2375a..82270e3eea0 100644
|
||||
--- a/src/App/Application.cpp
|
||||
+++ b/src/App/Application.cpp
|
||||
@@ -212,6 +212,22 @@ PyDoc_STRVAR(Base_doc,
|
||||
"like vector, matrix, bounding box, placement, rotation, axis, ...\n"
|
||||
);
|
||||
|
||||
+#if PY_MAJOR_VERSION >= 3
|
||||
+// This is called via the PyImport_AppendInittab mechanism called
|
||||
+// during initialization, to make the built-in __FreeCADBase__
|
||||
+// module known to Python.
|
||||
+PyMODINIT_FUNC
|
||||
+init_freecad_base_module(void)
|
||||
+{
|
||||
+ static struct PyModuleDef BaseModuleDef = {
|
||||
+ PyModuleDef_HEAD_INIT,
|
||||
+ "__FreeCADBase__", Base_doc, -1,
|
||||
+ NULL, NULL, NULL, NULL, NULL
|
||||
+ };
|
||||
+ return PyModule_Create(&BaseModuleDef);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
: _mConfig(mConfig), _pActiveDoc(0)
|
||||
{
|
||||
@@ -265,13 +281,7 @@ Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
// remove these types from the FreeCAD module.
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
- static struct PyModuleDef BaseModuleDef = {
|
||||
- PyModuleDef_HEAD_INIT,
|
||||
- "__FreeCADBase__", Base_doc, -1,
|
||||
- NULL, NULL, NULL, NULL, NULL
|
||||
- };
|
||||
- PyObject* pBaseModule = PyModule_Create(&BaseModuleDef);
|
||||
- _PyImport_FixupBuiltin(pBaseModule, "__FreeCADBase__");
|
||||
+ PyObject* pBaseModule = PyImport_ImportModule ("__FreeCADBase__");
|
||||
#else
|
||||
PyObject* pBaseModule = Py_InitModule3("__FreeCADBase__", NULL, Base_doc);
|
||||
#endif
|
||||
@@ -1416,6 +1426,9 @@ void Application::initConfig(int argc, char ** argv)
|
||||
# endif
|
||||
|
||||
// init python
|
||||
+#if PY_MAJOR_VERSION >= 3
|
||||
+ PyImport_AppendInittab ("__FreeCADBase__", init_freecad_base_module);
|
||||
+#endif
|
||||
mConfig["PythonSearchPath"] = Interpreter().init(argc,argv);
|
||||
|
||||
// Parse the options that have impact on the init process
|
Loading…
x
Reference in New Issue
Block a user