1{ lib 2, stdenv 3, buildPythonPackage 4, pythonOlder 5, fetchPypi 6, fetchpatch 7, isPyPy 8, substituteAll 9 10# build-system 11, setuptools 12 13# native dependencies 14, libGL 15 16# dependencies 17, numpy 18, pillow 19 20# optional-dependencies 21, astropy 22, av 23, imageio-ffmpeg 24, pillow-heif 25, psutil 26, tifffile 27 28# tests 29, pytestCheckHook 30, fsspec 31}: 32 33buildPythonPackage rec { 34 pname = "imageio"; 35 version = "2.32.0"; 36 pyproject = true; 37 38 disabled = pythonOlder "3.7"; 39 40 src = fetchPypi { 41 inherit pname version; 42 hash = "sha256-5CWtNsYFMI2eptk+2nsJh5JgWbi4YiDhQqWZp5dRKN0="; 43 }; 44 45 patches = [ 46 # pillow 10.1.0 compat 47 (fetchpatch { 48 name = "imageio-pillow-10.1.0-compat.patch"; 49 url = "https://github.com/imageio/imageio/commit/f58379c1ae7fbd1da8689937b39e499e2d225740.patch"; 50 hash = "sha256-jPSl/EUe69Dizkv8CqWpnm+TDPtF3VX2DkHOCEuYTLA="; 51 }) 52 ] ++ lib.optionals (!stdenv.isDarwin) [ 53 (substituteAll { 54 src = ./libgl-path.patch; 55 libgl = "${libGL.out}/lib/libGL${stdenv.hostPlatform.extensions.sharedLibrary}"; 56 }) 57 ]; 58 59 nativeBuildInputs = [ 60 setuptools 61 ]; 62 63 propagatedBuildInputs = [ 64 numpy 65 pillow 66 ]; 67 68 passthru.optional-dependencies = { 69 bsdf = []; 70 dicom = []; 71 feisem = []; 72 ffmpeg = [ 73 imageio-ffmpeg 74 psutil 75 ]; 76 fits = lib.optionals (!isPyPy) [ 77 astropy 78 ]; 79 freeimage = []; 80 lytro = []; 81 numpy = []; 82 pillow = []; 83 simpleitk = []; 84 spe = []; 85 swf = []; 86 tifffile = [ 87 tifffile 88 ]; 89 pyav = [ 90 av 91 ]; 92 heif = [ 93 pillow-heif 94 ]; 95 }; 96 97 nativeCheckInputs = [ 98 fsspec 99 psutil 100 pytestCheckHook 101 ] 102 ++ fsspec.optional-dependencies.github 103 ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); 104 105 pytestFlagsArray = [ 106 "-m 'not needs_internet'" 107 ]; 108 109 preCheck = '' 110 export IMAGEIO_USERDIR="$TMP" 111 export HOME=$TMPDIR 112 ''; 113 114 disabledTestPaths = [ 115 # tries to fetch fixtures over the network 116 "tests/test_freeimage.py" 117 "tests/test_pillow.py" 118 "tests/test_spe.py" 119 "tests/test_swf.py" 120 ]; 121 122 meta = with lib; { 123 description = "Library for reading and writing a wide range of image, video, scientific, and volumetric data formats"; 124 homepage = "https://imageio.readthedocs.io"; 125 changelog = "https://github.com/imageio/imageio/blob/v${version}/CHANGELOG.md"; 126 license = licenses.bsd2; 127 maintainers = with maintainers; [ Luflosi ]; 128 }; 129}