1# FIXME: make gdk_pixbuf dependency optional 2{ stdenv 3, buildPythonPackage 4, fetchPypi 5, lib 6, substituteAll 7, makeFontsConf 8, freefont_ttf 9, pytest 10, glibcLocales 11, cairo 12, cffi 13, withXcffib ? false, xcffib 14, python 15, glib 16, gdk_pixbuf }: 17 18buildPythonPackage rec { 19 pname = "cairocffi"; 20 version = "0.9.0"; 21 22 src = fetchPypi { 23 inherit pname version; 24 sha256 = "15386c3a9e08823d6826c4491eaccc7b7254b1dc587a3b9ce60c350c3f990337"; 25 }; 26 27 LC_ALL = "en_US.UTF-8"; 28 29 # checkPhase require at least one 'normal' font and one 'monospace', 30 # otherwise glyph tests fails 31 FONTCONFIG_FILE = makeFontsConf { 32 fontDirectories = [ freefont_ttf ]; 33 }; 34 35 checkInputs = [ pytest glibcLocales ]; 36 propagatedBuildInputs = [ cairo cffi ] ++ lib.optional withXcffib xcffib; 37 38 checkPhase = '' 39 py.test $out/${python.sitePackages} 40 ''; 41 42 patches = [ 43 # OSError: dlopen() failed to load a library: gdk_pixbuf-2.0 / gdk_pixbuf-2.0-0 44 (substituteAll { 45 src = ./dlopen-paths.patch; 46 ext = stdenv.hostPlatform.extensions.sharedLibrary; 47 cairo = cairo.out; 48 glib = glib.out; 49 gdk_pixbuf = gdk_pixbuf.out; 50 }) 51 ./fix_test_scaled_font.patch 52 ]; 53 54 meta = with lib; { 55 homepage = https://github.com/SimonSapin/cairocffi; 56 license = licenses.bsd3; 57 maintainers = with maintainers; []; 58 description = "cffi-based cairo bindings for Python"; 59 }; 60}