Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 150 lines 3.3 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 pythonOlder, 6 fetchFromGitHub, 7 8 # build-system 9 setuptools, 10 pkg-config, 11 12 # native dependencies 13 freetype, 14 lcms2, 15 libimagequant, 16 libjpeg, 17 libraqm, 18 libtiff, 19 libwebp, 20 libxcb, 21 openjpeg, 22 tkinter, 23 zlib, 24 25 # optional dependencies 26 defusedxml, 27 olefile, 28 typing-extensions, 29 30 # tests 31 numpy, 32 pytest-cov-stub, 33 pytestCheckHook, 34 35 # for passthru.tests 36 imageio, 37 matplotlib, 38 pilkit, 39 pydicom, 40 reportlab, 41 sage, 42}: 43 44buildPythonPackage rec { 45 pname = "pillow"; 46 version = "11.0.0"; 47 pyproject = true; 48 49 src = fetchFromGitHub { 50 owner = "python-pillow"; 51 repo = "pillow"; 52 rev = "refs/tags/${version}"; 53 hash = "sha256-vWNqzA2ZfJcWexXw790RgyYtP8WDtahoQIX16otCRnk="; 54 }; 55 56 build-system = [ setuptools ]; 57 58 nativeBuildInputs = [ pkg-config ]; 59 60 # https://pillow.readthedocs.io/en/latest/installation/building-from-source.html#building-from-source 61 buildInputs = [ 62 freetype 63 lcms2 64 libimagequant 65 libjpeg 66 libraqm 67 libtiff 68 libwebp 69 libxcb 70 openjpeg 71 tkinter 72 zlib 73 ]; 74 75 pypaBuildFlags = [ 76 # Disable platform guessing, which tries various FHS paths 77 "--config=setting=--disable-platform-guessing" 78 ]; 79 80 preConfigure = 81 let 82 getLibAndInclude = pkg: ''"${pkg.out}/lib", "${lib.getDev pkg}/include"''; 83 in 84 '' 85 # The build process fails to find the pkg-config files for these dependencies 86 substituteInPlace setup.py \ 87 --replace-fail 'IMAGEQUANT_ROOT = None' 'IMAGEQUANT_ROOT = ${getLibAndInclude libimagequant}' \ 88 --replace-fail 'JPEG2K_ROOT = None' 'JPEG2K_ROOT = ${getLibAndInclude openjpeg}' 89 90 # Build with X11 support 91 export LDFLAGS="$LDFLAGS -L${libxcb}/lib" 92 export CFLAGS="$CFLAGS -I${libxcb.dev}/include" 93 ''; 94 95 optional-dependencies = { 96 fpx = [ olefile ]; 97 mic = [ olefile ]; 98 typing = lib.optionals (pythonOlder "3.10") [ typing-extensions ]; 99 xmp = [ defusedxml ]; 100 }; 101 102 nativeCheckInputs = [ 103 pytest-cov-stub 104 pytestCheckHook 105 numpy 106 ] ++ lib.flatten (lib.attrValues optional-dependencies); 107 108 disabledTests = 109 [ 110 # Code quality mismathch 9 vs 10 111 "test_pyroma" 112 ] 113 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 114 # Disable darwin tests which require executables: `iconutil` and `screencapture` 115 "test_grab" 116 "test_grabclipboard" 117 "test_save" 118 ]; 119 120 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [ 121 # Crashes the interpreter 122 "Tests/test_imagetk.py" 123 ]; 124 125 passthru.tests = { 126 inherit 127 imageio 128 matplotlib 129 pilkit 130 pydicom 131 reportlab 132 sage 133 ; 134 }; 135 136 meta = with lib; { 137 homepage = "https://python-pillow.org"; 138 changelog = "https://pillow.readthedocs.io/en/stable/releasenotes/${version}.html"; 139 description = "Friendly PIL fork (Python Imaging Library)"; 140 longDescription = '' 141 The Python Imaging Library (PIL) adds image processing 142 capabilities to your Python interpreter. This library 143 supports many file formats, and provides powerful image 144 processing and graphics capabilities. 145 ''; 146 license = licenses.mit-cmu; 147 maintainers = with maintainers; [ hexa ]; 148 }; 149 150}