1 Patch dlopen() to allow direct paths to all required libs
3 This is an update of the patch submitted in
4 https://github.com/NixOS/nixpkgs/commit/b13e44e094989d3a902f8c73b22e8d3c0cc7acf4
5 by Alexander V. Nikolaev <avn@avnik.info>
8 cairocffi/__init__.py | 34 ++++++++++++++++------------------
9 1 file changed, 16 insertions(+), 18 deletions(-)
11 diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
12 index 307d58c..43c29e3 100644
13 --- a/cairocffi/__init__.py
14 +++ b/cairocffi/__init__.py
15 @@ -21,28 +21,26 @@ VERSION = __version__ = (Path(__file__).parent / 'VERSION').read_text().strip()
17 version_info = (1, 17, 2)
19 +# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be
20 +# required for runtime
22 + 'cairo': '@cairo@/lib/libcairo@ext@',
23 + 'glib-2.0': '@glib@/lib/libglib-2.0@ext@',
24 + 'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@',
25 + 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@',
29 def dlopen(ffi, library_names, filenames):
30 """Try various names for the same library, for different platforms."""
33 for library_name in library_names:
34 - library_filename = find_library(library_name)
35 - if library_filename:
36 - filenames = (library_filename,) + filenames
39 - 'no library called "{}" was found'.format(library_name))
41 - for filename in filenames:
43 - return ffi.dlopen(filename)
44 - except OSError as exception: # pragma: no cover
45 - exceptions.append(exception)
47 - error_message = '\n'.join( # pragma: no cover
48 - str(exception) for exception in exceptions)
49 - raise OSError(error_message) # pragma: no cover
50 + path = _LIBS.get(library_name, None)
52 + lib = ffi.dlopen(path)
56 + raise OSError("dlopen() failed to load a library: %s as %s" % (library_name, path))