summaryrefslogtreecommitdiffstats
path: root/src/tdedistutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tdedistutils.py')
-rw-r--r--src/tdedistutils.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/tdedistutils.py b/src/tdedistutils.py
index 45bdce2..a0f7971 100644
--- a/src/tdedistutils.py
+++ b/src/tdedistutils.py
@@ -896,15 +896,19 @@ class BuildKControlModule(Command):
#include <tqstring.h>
#include <sip.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif // _GNU_SOURCE
+#include <dlfcn.h>
+
#define MODULE_DIR "%(moduledir)s"
#define EXTRA_MODULE_DIR "%(extramodule)s"
#define MODULE_NAME "%(modulename)s"
#define FACTORY "%(factoryfunction)s"
#define CPP_FACTORY %(factoryfunction)s
-#define LIB_PYTHON "libpython%(python_version)s.so"
#define debug 1
-static TDECModule *report_error(char *msg) {
+static TDECModule *report_error(const char *msg) {
if (debug) printf ("error: %%s\n", msg);
return NULL;
}
@@ -914,15 +918,17 @@ static TDECModule* return_instance( TQWidget *parent, const char *name ) {
PyObject *pyTDECModuleTuple;
PyObject *pyTDECModule;
Pythonize *pyize; // Pythonize object to manage the Python interpreter.
- int isErr;
// Try to determine what py script we're loading. Note that "name"
// typically appears to be NULL.
TQString script(MODULE_NAME);
- // Reload libpython, but this time tell the runtime linker to make the
+ // Reload this module, but this time tell the runtime linker to make the
// symbols global and available for later loaded libraries/module.
- KLibLoader::self()->globalLibrary(LIB_PYTHON);
+ Dl_info info;
+ if (!dladdr((const void *)(&return_instance), &info) || !info.dli_fname || !dlopen(info.dli_fname, RTLD_GLOBAL|RTLD_NOW)) {
+ return report_error ("***Unable to export symbols\n");
+ }
// Start the interpreter.
pyize = initialize();
@@ -997,7 +1003,6 @@ static TDECModule* return_instance( TQWidget *parent, const char *name ) {
Py_INCREF(PyTuple_GET_ITEM(pyTDECModuleTuple,0));
// convert the TDECModule PyObject to a real C++ TDECModule *.
- isErr = 0;
pyTDECModule = PyTuple_GET_ITEM(pyTDECModuleTuple,1);
tdecmodule = (TDECModule *)PyLong_AsVoidPtr(pyTDECModule);
if(!tdecmodule) {