1Patch dlopen() to allow direct paths to all required libs
2
3This is an update of the patch submitted in
4https://github.com/NixOS/nixpkgs/commit/b13e44e094989d3a902f8c73b22e8d3c0cc7acf4
5by Alexander V. Nikolaev <avn@avnik.info>
6
7---
8 cairocffi/__init__.py | 34 ++++++++++++++++------------------
9 1 file changed, 16 insertions(+), 18 deletions(-)
10
11diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
12index 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()
16 version = '1.17.2'
17 version_info = (1, 17, 2)
18
19+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be
20+# required for runtime
21+_LIBS = {
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@',
26+}
27+
28
29 def dlopen(ffi, library_names, filenames):
30 """Try various names for the same library, for different platforms."""
31- exceptions = []
32-
33 for library_name in library_names:
34- library_filename = find_library(library_name)
35- if library_filename:
36- filenames = (library_filename,) + filenames
37- else:
38- exceptions.append(
39- 'no library called "{}" was found'.format(library_name))
40-
41- for filename in filenames:
42- try:
43- return ffi.dlopen(filename)
44- except OSError as exception: # pragma: no cover
45- exceptions.append(exception)
46-
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)
51+ if path:
52+ lib = ffi.dlopen(path)
53+ if lib:
54+ return lib
55+
56+ raise OSError("dlopen() failed to load a library: %s as %s" % (library_name, path))
57
58
59 cairo = dlopen(
60--
612.19.2