Initialize python home before calling any python primitive (#672)

This commit is contained in:
xarkes 2018-09-05 08:27:33 +02:00 committed by GitHub
parent c6260b5dcb
commit 66dcaea5bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -25,6 +25,10 @@ JupyterConnection *JupyterConnection::getInstance()
JupyterConnection::JupyterConnection(QObject *parent) : QObject(parent)
{
/* Will be removed/reworked with python plugins PR */
initPythonHome();
initPython();
qDebug() << "Python init";
}
JupyterConnection::~JupyterConnection()
@ -46,8 +50,7 @@ JupyterConnection::~JupyterConnection()
}
}
void JupyterConnection::initPython()
void JupyterConnection::initPythonHome()
{
#if defined(APPIMAGE) || defined(MACOS_PYTHON_FRAMEWORK_BUNDLED)
if (customPythonHome.isNull()) {
@ -72,6 +75,10 @@ void JupyterConnection::initPython()
Py_SetPythonHome(pythonHome);
}
}
void JupyterConnection::initPython()
{
PyImport_AppendInittab("cutter", &PyInit_api);
PyImport_AppendInittab("cutter_internal", &PyInit_api_internal);
Py_Initialize();

View File

@ -54,6 +54,7 @@ private:
wchar_t *pythonHome = nullptr;
void initPythonHome();
void initPython();
void createCutterJupyterModule();
};