1 Patch dlopen() to allow direct paths to all required libs
3 diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
4 index f917d90..31dab12 100644
5 --- a/cairocffi/__init__.py
6 +++ b/cairocffi/__init__.py
7 @@ -22,6 +22,14 @@ VERSION = __version__ = '1.7.1'
9 version_info = (1, 17, 2)
11 +# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be
12 +# required for runtime
14 + 'cairo': '@cairo@/lib/libcairo@ext@',
15 + 'glib-2.0': '@glib@/lib/libglib-2.0@ext@',
16 + 'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@',
17 + 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@',
20 # Python 3.8 no longer searches for DLLs in PATH, so we can add everything in
21 # CAIROCFFI_DLL_DIRECTORIES manually. Note that unlike PATH, add_dll_directory
22 @@ -36,26 +44,14 @@ if dll_directories and hasattr(os, 'add_dll_directory'):
24 def dlopen(ffi, library_names, filenames):
25 """Try various names for the same library, for different platforms."""
28 for library_name in library_names:
29 - library_filename = find_library(library_name)
30 - if library_filename:
31 - filenames = (library_filename, *filenames)
34 - 'no library called "{}" was found'.format(library_name))
36 - for filename in filenames:
38 - return ffi.dlopen(filename)
39 - except OSError as exception: # pragma: no cover
40 - exceptions.append(exception)
42 - error_message = '\n'.join( # pragma: no cover
43 - str(exception) for exception in exceptions)
44 - raise OSError(error_message) # pragma: no cover
45 + path = _LIBS.get(library_name, None)
47 + lib = ffi.dlopen(path)
51 + raise OSError("dlopen() failed to load a library: %s as %s" % (library_name, path))
54 ffi, ('cairo-2', 'cairo', 'libcairo-2'),