Skip to content

Commit

Permalink
Python: search for other names of libpython.so
Browse files Browse the repository at this point in the history
Some distros provide a libpython3.so symlink that points to the actual
libpython${major}.${minor}.so file. Other distros, such as Ubuntu, do
not. To prevent dlopen() from failing, we now attempt to load both
libpython3.so and libpython3.${minor}. This fixes the problem of
HDF5-UDF not finding symbols from libpython when loading the cffi
module.
  • Loading branch information
lucasvr committed Nov 19, 2020
1 parent 9d44e36 commit c68d1f2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/python_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ bool PythonBackend::run(
// Workaround for CFFI import errors due to missing symbols. We force libpython
// to be loaded and for all symbols to be resolved by dlopen()
void *libpython = dlopen("libpython3.so", RTLD_NOW | RTLD_GLOBAL);
if (! libpython)
{
char libname[64];
snprintf(libname, sizeof(libname)-1, "libpython3.%d.so", PY_MINOR_VERSION);
libpython = dlopen(libname, RTLD_NOW | RTLD_GLOBAL);
}

// Init Python interpreter
Py_Initialize();
Expand Down

0 comments on commit c68d1f2

Please sign in to comment.