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