1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 isPyPy,
7 replaceVars,
8
9 # build-system
10 setuptools,
11
12 # native dependencies
13 libGL,
14
15 # dependencies
16 numpy,
17 pillow,
18
19 # optional-dependencies
20 astropy,
21 av,
22 imageio-ffmpeg,
23 pillow-heif,
24 psutil,
25 tifffile,
26
27 # tests
28 pytestCheckHook,
29 fsspec,
30}:
31
32buildPythonPackage rec {
33 pname = "imageio";
34 version = "2.37.0";
35 pyproject = true;
36
37 src = fetchFromGitHub {
38 owner = "imageio";
39 repo = "imageio";
40 tag = "v${version}";
41 hash = "sha256-/nxJxZrTYX7F2grafIWwx9SyfR47ZXyaUwPHMEOdKkI=";
42 };
43
44 patches = lib.optionals (!stdenv.hostPlatform.isDarwin) [
45 (replaceVars ./libgl-path.patch {
46 libgl = "${libGL.out}/lib/libGL${stdenv.hostPlatform.extensions.sharedLibrary}";
47 })
48 ];
49
50 build-system = [ setuptools ];
51
52 dependencies = [
53 numpy
54 pillow
55 ];
56
57 optional-dependencies = {
58 bsdf = [ ];
59 dicom = [ ];
60 feisem = [ ];
61 ffmpeg = [
62 imageio-ffmpeg
63 psutil
64 ];
65 fits = lib.optionals (!isPyPy) [ astropy ];
66 freeimage = [ ];
67 lytro = [ ];
68 numpy = [ ];
69 pillow = [ ];
70 simpleitk = [ ];
71 spe = [ ];
72 swf = [ ];
73 tifffile = [ tifffile ];
74 pyav = [ av ];
75 heif = [ pillow-heif ];
76 };
77
78 nativeCheckInputs =
79 [
80 fsspec
81 psutil
82 pytestCheckHook
83 ]
84 ++ fsspec.optional-dependencies.github
85 ++ lib.flatten (builtins.attrValues optional-dependencies);
86
87 pytestFlagsArray = [ "-m 'not needs_internet'" ];
88
89 preCheck = ''
90 export IMAGEIO_USERDIR=$(mktemp -d)
91 export HOME=$(mktemp -d)
92 '';
93
94 meta = {
95 description = "Library for reading and writing a wide range of image, video, scientific, and volumetric data formats";
96 homepage = "https://imageio.readthedocs.io";
97 changelog = "https://github.com/imageio/imageio/blob/${src.tag}/CHANGELOG.md";
98 license = lib.licenses.bsd2;
99 maintainers = with lib.maintainers; [ Luflosi ];
100 };
101}