git.iko.soy/typeable/nixpkgs
on master help sign in
cairocffi: Add missing dependencies on gdk_pixbuf

Rewrite dlopening stuff in hacky way (due ctypes.util totally brokennes: it attempt to use /sbin/ldconfig, gcc from PATH and other tricks to detect sonames, I replaced it with simple table lookup) Also I add patch to bypass another rounding regression in tests (this patch submitted upstream as well)

commitb13e44e094989d3a902f8c73b22e8d3c0cc7acf4 authorAlexander V. Nikolaev <avn@avnik.info> dateSat 6 Feb 2016, 09:11 (11 years ago) parentb99e339
2 files changed+63−4
pkgs/development/python-modules/cairocffi/dlopen-paths.patch+47 pkgs/top-level/python-packages.nix+16−4
pkgs/development/python-modules/cairocffi/dlopen-paths.patchnew file+47
@@ -0,0 +1,47 @@
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')
pkgs/top-level/python-packages.nix+16−4
@@ -2623,17 +2623,29 @@ in modules // {
26232623 py.test $out/${python.sitePackages}
26242624 '';
26252625
2626− # Marked broken since according to test
2626+ # FIXME: make gdk_pixbuf dependency optional (as wel as xcfffi)
26272627 # Happens with 0.7.1 and 0.7.2
26282628 # OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0
26292629
2630− patchPhase = ''
2630+ 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 = ''
26312641 # Hardcode cairo library path
2632− sed -e 's,ffi\.dlopen(,&"${pkgs.cairo}/lib/" + ,' -i cairocffi/__init__.py
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}
26332646 '';
26342647
26352648 meta = {
2636− broken = true;
26372649 homepage = https://github.com/SimonSapin/cairocffi;
26382650 license = "bsd";
26392651 description = "cffi-based cairo bindings for Python";