Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.

Commit 2078be9

Browse files
committed
Do not preload Python's .so library
1 parent fd6c25d commit 2078be9

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/PythonQt.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,20 +337,22 @@ PythonQt* PythonQt::self() { return _self; }
337337

338338
PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName)
339339
{
340-
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8 && defined(__linux__)
340+
// #if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8 && defined(__linux__)
341341
/* Starting from python 3.8, python C extensions no longer link to libpython3.X.so
342-
This is a problem, since libpython3.X.so is loaded through a reference in libtrikScriptRunner.so
342+
This is a possible problem, since libpython3.X.so is loaded through a reference in libtrikScriptRunner.so
343343
and (somehow) ld.so does not place it's symbols into global symbol table. This results into a failure to load any C module.
344344
Loading libpython3.X.so with dlopen and RTLD_GLOBAL flag effectively solves this issue. */
345345

346346
// TODO: Someting like PyRun_String("sysconfig.get_config_var('LDLIBRARY')")
347347
// should be used to extract shared object name for current interpreter
348-
const auto &libName = QString("libpython3.%1.so.1.0").arg(PY_MINOR_VERSION).toStdString();
349-
if (NULL == dlopen(libName.c_str(), RTLD_GLOBAL | RTLD_LAZY)) {
350-
qFatal("Failed to load %s", libName.c_str());
351-
abort();
352-
}
353-
#endif
348+
349+
// NOTE 2023-07-07: On Centos7 .so is a link named `libpython3.8.so` and points to `libpython3.8.so.rh-python38-1.0`
350+
// const auto &libName = QString("libpython3.%1.so.1.0").arg(PY_MINOR_VERSION).toStdString();
351+
// if (NULL == dlopen(libName.c_str(), RTLD_GLOBAL | RTLD_LAZY)) {
352+
//qFatal("Failed to load %s", libName.c_str());
353+
//abort();
354+
// }
355+
// #endif
354356
_p = new PythonQtPrivate;
355357
_p->_initFlags = flags;
356358

0 commit comments

Comments
 (0)