···1+commit 705dc9a55bd160625d9996e63fc7dc532d0ad0ab
2+Author: Alexander V. Nikolaev <avn@avnik.info>
3+Date: Sat Feb 6 08:09:06 2016 +0200
4+5+ Patch dlopen() to allow direct paths to all required libs
6+7+ This patch is NixOS specific
8+9+diff --git a/cairocffi/__init__.py b/cairocffi/__init__.py
10+index 718aa7f..1a1dcff 100644
11+--- a/cairocffi/__init__.py
12++++ b/cairocffi/__init__.py
13+@@ -27,20 +27,22 @@ VERSION = '0.7.2'
14+ version = '1.10.0'
15+ version_info = (1, 10, 0)
16+17++# Use hardcoded soname, because ctypes.util use gcc/objdump which shouldn't be required for runtime
18++_LIBS = {
19++ 'cairo': '@cairo@/lib/libcairo.so.2',
20++ 'glib-2.0': '@glib@/lib/libglib-2.0.so.0',
21++ 'gobject-2.0': '@glib@/lib/libgobject-2.0.so.0',
22++ 'gdk_pixbuf-2.0': '@gdk_pixbuf@/lib/libgdk_pixbuf-2.0.so.0',
23++}
24+25+-def dlopen(ffi, *names):
26++def dlopen(ffi, name, *names):
27+ """Try various names for the same library, for different platforms."""
28+- for name in names:
29+- for lib_name in [name, 'lib' + name]:
30+- try:
31+- path = ctypes.util.find_library(lib_name)
32+- if path:
33+- lib = ffi.dlopen(path)
34+- if lib:
35+- return lib
36+- except OSError:
37+- pass
38+- raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
39++ path = _LIBS.get(name, None)
40++ if path:
41++ lib = ffi.dlopen(path)
42++ if lib:
43++ return lib
44++ raise OSError("dlopen() failed to load a library: %s as %s" % (name, path))
45+46+47+ cairo = dlopen(ffi, 'cairo', 'cairo-2')
+23-4
pkgs/top-level/python-packages.nix
···2609 };
26102611 LC_ALL = "en_US.UTF-8";
00000002612 buildInputs = with self; [ pytest pkgs.glibcLocales ];
2613 propagatedBuildInputs = with self; [ pkgs.cairo cffi ];
2614···2616 py.test $out/${python.sitePackages}
2617 '';
26182619- # Marked broken since according to test
2620 # Happens with 0.7.1 and 0.7.2
2621 # OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0
26222623- patchPhase = ''
00000000002624 # Hardcode cairo library path
2625- sed -e 's,ffi\.dlopen(,&"${pkgs.cairo}/lib/" + ,' -i cairocffi/__init__.py
0002626 '';
26272628 meta = {
2629- broken = true;
2630 homepage = https://github.com/SimonSapin/cairocffi;
2631 license = "bsd";
2632 description = "cffi-based cairo bindings for Python";
···2609 };
26102611 LC_ALL = "en_US.UTF-8";
2612+2613+ # checkPhase require at least one 'normal' font and one 'monospace',
2614+ # otherwise glyph tests fails
2615+ FONTCONFIG_FILE = pkgs.makeFontsConf {
2616+ fontDirectories = [ pkgs.freefont_ttf ];
2617+ };
2618+2619 buildInputs = with self; [ pytest pkgs.glibcLocales ];
2620 propagatedBuildInputs = with self; [ pkgs.cairo cffi ];
2621···2623 py.test $out/${python.sitePackages}
2624 '';
26252626+ # FIXME: make gdk_pixbuf dependency optional (as wel as xcfffi)
2627 # Happens with 0.7.1 and 0.7.2
2628 # OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0
26292630+ patches = [
2631+ # This patch from PR substituted upstream
2632+ (pkgs.fetchpatch {
2633+ url = "https://github.com/avnik/cairocffi/commit/2266882e263c5efc87350cf016d117b2ec6a1d59.patch";
2634+ sha256 = "0gb570z3ivf1b0ixsk526n3h29m8c5rhjsiyam7rr3x80dp65cdl";
2635+ })
2636+2637+ ../development/python-modules/cairocffi/dlopen-paths.patch
2638+ ];
2639+2640+ postPatch = ''
2641 # Hardcode cairo library path
2642+ # FIXME: for closure-size branch all pkgs.foo should be replaced with pkgs.foo.lib
2643+ substituteInPlace cairocffi/__init__.py --subst-var-by cairo ${pkgs.cairo}
2644+ substituteInPlace cairocffi/__init__.py --subst-var-by glib ${pkgs.glib}
2645+ substituteInPlace cairocffi/__init__.py --subst-var-by gdk_pixbuf ${pkgs.gdk_pixbuf}
2646 '';
26472648 meta = {
02649 homepage = https://github.com/SimonSapin/cairocffi;
2650 license = "bsd";
2651 description = "cffi-based cairo bindings for Python";