py3: port external FreeCAD module to Python3

issue 0000995
This commit is contained in:
wmayer
2017-06-02 06:39:06 +02:00
committed by looooo
parent f072d2e627
commit d40d68d0cb
3 changed files with 71 additions and 37 deletions

View File

@@ -319,7 +319,11 @@ QWidget* setupMainWindow()
return Gui::getMainWindow();
}
#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC PyInit_FreeCADGui()
#else
PyMODINIT_FUNC initFreeCADGui()
#endif
{
try {
Base::Interpreter().loadModule("FreeCAD");
@@ -327,7 +331,13 @@ PyMODINIT_FUNC initFreeCADGui()
App::Application::Config()["SplashScreen"] = "freecadsplash";
App::Application::Config()["CopyrightInfo"] = "\xc2\xa9 Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2017\n";
Gui::Application::initApplication();
Py_InitModule("FreeCADGui", FreeCADGui_methods);
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef FreeCADGuiModuleDef = {PyModuleDef_HEAD_INIT,"FreeCADGui", "FreeCAD GUI module\n", -1, FreeCADGui_methods};
PyObject* module = PyModule_Create(&FreeCADGuiModuleDef);
return module;
#else
Py_InitModule3("FreeCADGui", FreeCADGui_methods, "FreeCAD GUI module\n");
#endif
}
catch (const Base::Exception& e) {
PyErr_Format(PyExc_ImportError, "%s\n", e.what());
@@ -335,5 +345,8 @@ PyMODINIT_FUNC initFreeCADGui()
catch (...) {
PyErr_SetString(PyExc_ImportError, "Unknown runtime error occurred");
}
#if PY_MAJOR_VERSION >= 3
return 0;
#endif
}