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