Skip to content
This repository was archived by the owner on Jun 25, 2022. It is now read-only.

Commit a7b5ecf

Browse files
author
pathmann
committed
allow loading cpython modules not exporting python symbols
1 parent 9aae8d4 commit a7b5ecf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

shared/pythonhost.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#else
1717
//mac + linux
1818
#define INTERPRETER "python"
19+
20+
#include <dlfcn.h>
1921
#endif
2022

2123
PythonHost::PythonHost(): m_interpreter(NULL), m_trace(NULL), m_inited(false) {
@@ -263,6 +265,16 @@ bool PythonHost::init(const QDir& basedir, QString& error) {
263265
return false;
264266
}
265267

268+
#ifdef Q_OS_UNIX
269+
PyThreadState* tstate = PyThreadState_GET();
270+
if (!tstate) {
271+
error = QObject::tr("Error getting Threadstate");
272+
return false;
273+
}
274+
275+
tstate->interp->dlopenflags = tstate->interp->dlopenflags | RTLD_GLOBAL;
276+
#endif
277+
266278
if (!setSysPath(error))
267279
return false;
268280

0 commit comments

Comments
 (0)