at 24.11-pre 3.1 kB view raw
1{ 2 pname, 3 version, 4 disabled, 5 src, 6 patches ? [ ], 7 meta, 8 passthru ? { }, 9 ... 10}@args: 11 12with args; 13 14buildPythonPackage rec { 15 inherit 16 pname 17 version 18 format 19 src 20 meta 21 passthru 22 patches 23 ; 24 25 # Disable imagefont tests, because they don't work well with infinality: 26 # https://github.com/python-pillow/Pillow/issues/1259 27 postPatch = '' 28 rm Tests/test_imagefont.py 29 ''; 30 31 disabledTests = 32 [ 33 # Code quality mismathch 9 vs 10 34 "test_pyroma" 35 36 # pillow-simd 37 "test_roundtrip" 38 "test_basic" 39 "test_custom_metadata" 40 ] 41 ++ lib.optionals stdenv.isDarwin [ 42 # Disable darwin tests which require executables: `iconutil` and `screencapture` 43 "test_grab" 44 "test_grabclipboard" 45 "test_save" 46 ]; 47 48 propagatedBuildInputs = [ 49 olefile 50 ] ++ lib.optionals (lib.versionAtLeast version "8.2.0") [ defusedxml ]; 51 52 nativeCheckInputs = [ 53 pytestCheckHook 54 numpy 55 ]; 56 57 nativeBuildInputs = [ setuptools ]; 58 59 buildInputs = 60 [ 61 freetype 62 libjpeg 63 openjpeg 64 libimagequant 65 zlib 66 libtiff 67 libwebp 68 libxcrypt 69 tcl 70 lcms2 71 ] 72 ++ lib.optionals (lib.versionAtLeast version "7.1.0") [ libxcb ] 73 ++ lib.optionals (isPyPy) [ 74 tk 75 libX11 76 ]; 77 78 # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp. 79 # NOTE: The Pillow install script will, by default, add paths like /usr/lib 80 # and /usr/include to the search paths. This can break things when building 81 # on a non-NixOS system that has some libraries installed that are not 82 # installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't 83 # build Pillow with this support). We patch the `disable_platform_guessing` 84 # setting here, instead of passing the `--disable-platform-guessing` 85 # command-line option, since the command-line option doesn't work when we run 86 # tests. 87 preConfigure = 88 let 89 libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"''; 90 libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"''; 91 in 92 '' 93 sed -i "setup.py" \ 94 -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ; 95 s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ; 96 s|^JPEG2K_ROOT =.*$|JPEG2K_ROOT = ${libinclude openjpeg}|g ; 97 s|^IMAGEQUANT_ROOT =.*$|IMAGEQUANT_ROOT = ${libinclude' libimagequant}|g ; 98 s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ; 99 s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ; 100 s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ; 101 s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ; 102 s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;' 103 export LDFLAGS="$LDFLAGS -L${libwebp}/lib" 104 export CFLAGS="$CFLAGS -I${libwebp}/include" 105 '' 106 + lib.optionalString (lib.versionAtLeast version "7.1.0") '' 107 export LDFLAGS="$LDFLAGS -L${libxcb}/lib" 108 export CFLAGS="$CFLAGS -I${libxcb.dev}/include" 109 ''; 110}