1{ stdenv, buildPythonPackage, fetchPypi, isPyPy,
2 nose, olefile,
3 freetype, libjpeg, zlib, libtiff, libwebp, tcl, lcms2, tk, libX11}:
4buildPythonPackage rec {
5 pname = "Pillow";
6 version = "4.2.1";
7 name = "${pname}-${version}";
8
9 src = fetchPypi {
10 inherit pname version;
11 sha256 = "0wq0fiw964bj5rdmw66mhbfsjnmb13bcdr42krpk2ig5f1cgc967";
12 };
13
14 doCheck = !stdenv.isDarwin && !isPyPy;
15
16 # Disable imagefont tests, because they don't work well with infinality:
17 # https://github.com/python-pillow/Pillow/issues/1259
18 postPatch = ''
19 rm Tests/test_imagefont.py
20 '';
21
22 propagatedBuildInputs = [ olefile ];
23
24 buildInputs = [
25 freetype libjpeg zlib libtiff libwebp tcl nose lcms2 ]
26 ++ stdenv.lib.optionals (isPyPy) [ tk libX11 ];
27
28 # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp.
29 preConfigure = let
30 libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"'';
31 libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"'';
32 in ''
33 sed -i "setup.py" \
34 -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ;
35 s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ;
36 s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ;
37 s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ;
38 s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ;
39 s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ;'
40 export LDFLAGS="-L${libwebp}/lib"
41 export CFLAGS="-I${libwebp}/include"
42 ''
43 # Remove impurities
44 + stdenv.lib.optionalString stdenv.isDarwin ''
45 substituteInPlace setup.py \
46 --replace '"/Library/Frameworks",' "" \
47 --replace '"/System/Library/Frameworks"' ""
48 '';
49
50 meta = with stdenv.lib; {
51 homepage = https://python-pillow.github.io/;
52 description = "Fork of The Python Imaging Library (PIL)";
53 longDescription = ''
54 The Python Imaging Library (PIL) adds image processing
55 capabilities to your Python interpreter. This library
56 supports many file formats, and provides powerful image
57 processing and graphics capabilities.
58 '';
59 license = "http://www.pythonware.com/products/pil/license.htm";
60 maintainers = with maintainers; [ goibhniu prikhi ];
61 };
62}