about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/cairocffi/dlopen-paths-0.9.patch
blob: 862f7bd4bf7ce4c3a13c8b1f8fbd78669289040d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
commit 705dc9a55bd160625d9996e63fc7dc532d0ad0ab
Author: Alexander V. Nikolaev <avn@avnik.info>
Date:   Sat Feb 6 08:09:06 2016 +0200

    Patch dlopen() to allow direct paths to all required libs
    
    This patch is NixOS specific

diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
index 718aa7f..1a1dcff 100644
--- a/cairocffi/__init__.py
+++ b/cairocffi/__init__.py
@@ -27,20 +27,22 @@ VERSION = '0.7.2'
 version = '1.10.0'
 version_info = (1, 10, 0)
 
+# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
+_LIBS = {
+    'cairo': '@cairo@/lib/libcairo@ext@',
+    'glib-2.0': '@glib@/lib/libglib-2.0@ext@',
+    'gobject-2.0': '@glib@/lib/libgobject-2.0@ext@',
+    'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0@ext@',
+}
 
-def dlopen(ffi, *names):
+def dlopen(ffi, name, *names):
     """Try various names for the same library, for different platforms."""
-    for name in names:
-        for lib_name in [name, 'lib' + name]:
-            try:
-                path = ctypes.util.find_library(lib_name)
-                if path:
-                    lib = ffi.dlopen(path)
-                    if lib:
-                        return lib
-            except OSError:
-                pass
-    raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
+    path = _LIBS.get(name, None)
+    if path:
+        lib = ffi.dlopen(path)
+        if lib:
+            return lib
+    raise OSError("dlopen() failed to load a library: %s as %s" % (name, path))
 
 
 cairo = dlopen(ffi, 'cairo', 'cairo-2')