1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 isPyPy, 7 8 # build-system 9 setuptools, 10 11 # native dependencies 12 libGL, 13 14 # dependencies 15 numpy, 16 pillow, 17 18 # optional-dependencies 19 astropy, 20 av, 21 imageio-ffmpeg, 22 pillow-heif, 23 psutil, 24 tifffile, 25 26 # tests 27 pytestCheckHook, 28 gitMinimal, 29 fsspec, 30}: 31 32let 33 test_images = fetchFromGitHub { 34 owner = "imageio"; 35 repo = "test_images"; 36 rev = "f676c96b1af7e04bb1eed1e4551e058eb2f14acd"; 37 leaveDotGit = true; 38 hash = "sha256-Kh8DowuhcCT5C04bE5yJa2C+efilLxP0AM31XjnHRf4="; 39 }; 40 libgl = "${libGL.out}/lib/libGL${stdenv.hostPlatform.extensions.sharedLibrary}"; 41in 42 43buildPythonPackage rec { 44 pname = "imageio"; 45 version = "2.37.0"; 46 pyproject = true; 47 48 src = fetchFromGitHub { 49 owner = "imageio"; 50 repo = "imageio"; 51 tag = "v${version}"; 52 hash = "sha256-/nxJxZrTYX7F2grafIWwx9SyfR47ZXyaUwPHMEOdKkI="; 53 }; 54 55 postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 56 substituteInPlace tests/test_core.py \ 57 --replace-fail 'ctypes.util.find_library("GL")' '"${libgl}"' 58 ''; 59 60 build-system = [ setuptools ]; 61 62 dependencies = [ 63 numpy 64 pillow 65 ]; 66 67 optional-dependencies = { 68 bsdf = [ ]; 69 dicom = [ ]; 70 feisem = [ ]; 71 ffmpeg = [ 72 imageio-ffmpeg 73 psutil 74 ]; 75 fits = lib.optionals (!isPyPy) [ astropy ]; 76 freeimage = [ ]; 77 lytro = [ ]; 78 numpy = [ ]; 79 pillow = [ ]; 80 simpleitk = [ ]; 81 spe = [ ]; 82 swf = [ ]; 83 tifffile = [ tifffile ]; 84 pyav = [ av ]; 85 heif = [ pillow-heif ]; 86 }; 87 88 nativeCheckInputs = [ 89 fsspec 90 gitMinimal 91 psutil 92 pytestCheckHook 93 ] 94 ++ fsspec.optional-dependencies.github 95 ++ lib.flatten (builtins.attrValues optional-dependencies); 96 97 pytestFlags = [ "--test-images=file://${test_images}" ]; 98 99 # These should have had `needs_internet` mark applied but don't so far. 100 # See https://github.com/imageio/imageio/pull/1142 101 disabledTests = [ 102 "test_read_stream" 103 "test_uri_reading" 104 "test_trim_filter" 105 ]; 106 107 disabledTestMarks = [ "needs_internet" ]; 108 109 # These tests require the old and vulnerable freeimage binaries; skip. 110 disabledTestPaths = [ "tests/test_freeimage.py" ]; 111 112 preCheck = '' 113 export IMAGEIO_USERDIR=$(mktemp -d) 114 export HOME=$(mktemp -d) 115 ''; 116 117 meta = { 118 description = "Library for reading and writing a wide range of image, video, scientific, and volumetric data formats"; 119 homepage = "https://imageio.readthedocs.io"; 120 changelog = "https://github.com/imageio/imageio/blob/${src.tag}/CHANGELOG.md"; 121 license = lib.licenses.bsd2; 122 maintainers = with lib.maintainers; [ Luflosi ]; 123 }; 124}