-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #4333. Do the same dlopen stuff for the new-style API.
This is required so that the old one can be imported second on Linux/Mac.
- Loading branch information
1 parent
1335da9
commit 1cca624
Showing
7 changed files
with
121 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Code/Mantid/Framework/PythonInterface/mantid/kernel/src/dlopen.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <Python.h> | ||
#include <dlfcn.h> | ||
|
||
|
||
PyObject * loadLibrary(PyObject *self, PyObject * args) | ||
{ | ||
(void)self; | ||
const char *filename; | ||
if (!PyArg_ParseTuple(args, "s", &filename)) | ||
{ | ||
PyErr_SetString(PyExc_ValueError, "Invalid string object"); | ||
return NULL; | ||
} | ||
|
||
void* handle = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); | ||
if (!handle) | ||
{ | ||
PyErr_SetString(PyExc_RuntimeError, dlerror()); | ||
return NULL; | ||
} | ||
Py_INCREF(Py_None); | ||
return Py_None; | ||
} | ||
|
||
|
||
void init_module_libdlopen(); | ||
|
||
static PyMethodDef dlopen_methods[] = { | ||
{"loadlibrary", loadLibrary, METH_VARARGS, | ||
"Load a library with dlopen and RTLD flags"}, | ||
{NULL, NULL, 0, NULL} /* Sentinel */ | ||
}; | ||
|
||
void init_dlopen() | ||
{ | ||
PyObject *m; | ||
|
||
m = Py_InitModule("_dlopen", dlopen_methods); | ||
if (m == NULL) return; | ||
} | ||
|