at 23.05-pre 3.1 kB view raw
1{ pname 2, version 3, disabled 4, src 5, patches ? [] 6, meta 7, passthru ? {} 8, ... 9}@args: 10 11with args; 12 13buildPythonPackage rec { 14 inherit pname version src meta passthru patches; 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 # Disable darwin tests which require executables: `iconutil` and `screencapture` 23 disabledTests = lib.optionals stdenv.isDarwin [ 24 "test_grab" 25 "test_grabclipboard" 26 "test_save" 27 28 # pillow-simd 29 "test_roundtrip" 30 "test_basic" 31 ] ++ lib.optionals (lib.versions.major version == "6") [ 32 # RuntimeError: Error setting from dictionary 33 "test_custom_metadata" 34 ]; 35 36 propagatedBuildInputs = [ olefile ] 37 ++ lib.optionals (lib.versionAtLeast version "8.2.0") [ defusedxml ]; 38 39 checkInputs = [ pytestCheckHook pyroma numpy ]; 40 41 buildInputs = [ freetype libjpeg openjpeg libimagequant zlib libtiff libwebp libxcrypt tcl lcms2 ] 42 ++ lib.optionals (lib.versionAtLeast version "7.1.0") [ libxcb ] 43 ++ lib.optionals (isPyPy) [ tk libX11 ]; 44 45 # NOTE: we use LCMS_ROOT as WEBP root since there is not other setting for webp. 46 # NOTE: The Pillow install script will, by default, add paths like /usr/lib 47 # and /usr/include to the search paths. This can break things when building 48 # on a non-NixOS system that has some libraries installed that are not 49 # installed in Nix (for example, Arch Linux has jpeg2000 but Nix doesn't 50 # build Pillow with this support). We patch the `disable_platform_guessing` 51 # setting here, instead of passing the `--disable-platform-guessing` 52 # command-line option, since the command-line option doesn't work when we run 53 # tests. 54 preConfigure = let 55 libinclude' = pkg: ''"${pkg.out}/lib", "${pkg.out}/include"''; 56 libinclude = pkg: ''"${pkg.out}/lib", "${pkg.dev}/include"''; 57 in '' 58 sed -i "setup.py" \ 59 -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = ${libinclude freetype}|g ; 60 s|^JPEG_ROOT =.*$|JPEG_ROOT = ${libinclude libjpeg}|g ; 61 s|^JPEG2K_ROOT =.*$|JPEG2K_ROOT = ${libinclude openjpeg}|g ; 62 s|^IMAGEQUANT_ROOT =.*$|IMAGEQUANT_ROOT = ${libinclude' libimagequant}|g ; 63 s|^ZLIB_ROOT =.*$|ZLIB_ROOT = ${libinclude zlib}|g ; 64 s|^LCMS_ROOT =.*$|LCMS_ROOT = ${libinclude lcms2}|g ; 65 s|^TIFF_ROOT =.*$|TIFF_ROOT = ${libinclude libtiff}|g ; 66 s|^TCL_ROOT=.*$|TCL_ROOT = ${libinclude' tcl}|g ; 67 s|self\.disable_platform_guessing = None|self.disable_platform_guessing = True|g ;' 68 export LDFLAGS="$LDFLAGS -L${libwebp}/lib" 69 export CFLAGS="$CFLAGS -I${libwebp}/include" 70 '' + lib.optionalString (lib.versionAtLeast version "7.1.0") '' 71 export LDFLAGS="$LDFLAGS -L${libxcb}/lib" 72 export CFLAGS="$CFLAGS -I${libxcb.dev}/include" 73 '' + lib.optionalString stdenv.isDarwin '' 74 # Remove impurities 75 substituteInPlace setup.py \ 76 --replace '"/Library/Frameworks",' "" \ 77 --replace '"/System/Library/Frameworks"' "" 78 ''; 79}