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