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