1{ lib
2, stdenv
3, buildPythonPackage
4, pythonOlder
5, fetchFromGitHub
6, isPyPy
7, substituteAll
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.33.0";
35 pyproject = true;
36
37 disabled = pythonOlder "3.8";
38
39 src = fetchFromGitHub {
40 owner = "imageio";
41 repo = "imageio";
42 rev = "refs/tags/v${version}";
43 hash = "sha256-WoCycrJxo0vyV9LiWnEag1wbld3EJWu8mks8TnYt2+A=";
44 };
45
46 patches = lib.optionals (!stdenv.isDarwin) [
47 (substituteAll {
48 src = ./libgl-path.patch;
49 libgl = "${libGL.out}/lib/libGL${stdenv.hostPlatform.extensions.sharedLibrary}";
50 })
51 ];
52
53 nativeBuildInputs = [
54 setuptools
55 ];
56
57 propagatedBuildInputs = [
58 numpy
59 pillow
60 ];
61
62 passthru.optional-dependencies = {
63 bsdf = [];
64 dicom = [];
65 feisem = [];
66 ffmpeg = [
67 imageio-ffmpeg
68 psutil
69 ];
70 fits = lib.optionals (!isPyPy) [
71 astropy
72 ];
73 freeimage = [];
74 lytro = [];
75 numpy = [];
76 pillow = [];
77 simpleitk = [];
78 spe = [];
79 swf = [];
80 tifffile = [
81 tifffile
82 ];
83 pyav = [
84 av
85 ];
86 heif = [
87 pillow-heif
88 ];
89 };
90
91 nativeCheckInputs = [
92 fsspec
93 psutil
94 pytestCheckHook
95 ]
96 ++ fsspec.optional-dependencies.github
97 ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
98
99 pytestFlagsArray = [
100 "-m 'not needs_internet'"
101 ];
102
103 preCheck = ''
104 export IMAGEIO_USERDIR="$TMP"
105 export HOME=$TMPDIR
106 '';
107
108 disabledTestPaths = [
109 # tries to fetch fixtures over the network
110 "tests/test_freeimage.py"
111 "tests/test_pillow.py"
112 "tests/test_spe.py"
113 "tests/test_swf.py"
114 ];
115
116 disabledTests = lib.optionals stdenv.isDarwin [
117 # Segmentation fault
118 "test_bayer_write"
119 # RuntimeError: No valid H.264 encoder was found with the ffmpeg installation
120 "test_writer_file_properly_closed"
121 "test_writer_pixelformat_size_verbose"
122 "test_writer_ffmpeg_params"
123 "test_reverse_read"
124 ];
125
126 meta = with lib; {
127 description = "Library for reading and writing a wide range of image, video, scientific, and volumetric data formats";
128 homepage = "https://imageio.readthedocs.io";
129 changelog = "https://github.com/imageio/imageio/blob/v${version}/CHANGELOG.md";
130 license = licenses.bsd2;
131 maintainers = with maintainers; [ Luflosi ];
132 };
133}