1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 pythonOlder,
6 hatchling,
7 hatch-vcs,
8 numpy,
9 packaging,
10 importlib-resources,
11 typing-extensions,
12 pydicom,
13 pillow,
14 h5py,
15 scipy,
16 git,
17 pytest-doctestplus,
18 pytest-httpserver,
19 pytest-xdist,
20 pytest7CheckHook,
21}:
22
23buildPythonPackage rec {
24 pname = "nibabel";
25 version = "5.3.2";
26 pyproject = true;
27
28 disabled = pythonOlder "3.9";
29
30 src = fetchPypi {
31 inherit pname version;
32 hash = "sha256-C9ymUDsceEtEbHRaRUI2fed1bPug1yFDuR+f+3i+Vps=";
33 };
34
35 build-system = [
36 hatchling
37 hatch-vcs
38 ];
39
40 dependencies =
41 [
42 numpy
43 packaging
44 ]
45 ++ lib.optionals (pythonOlder "3.12") [ importlib-resources ]
46 ++ lib.optionals (pythonOlder "3.13") [ typing-extensions ];
47
48 optional-dependencies = rec {
49 all = dicom ++ dicomfs ++ minc2 ++ spm ++ zstd;
50 dicom = [ pydicom ];
51 dicomfs = [ pillow ] ++ dicom;
52 minc2 = [ h5py ];
53 spm = [ scipy ];
54 zstd = [
55 # TODO: pyzstd
56 ];
57 };
58
59 nativeCheckInputs = [
60 git
61 pytest-doctestplus
62 pytest-httpserver
63 pytest-xdist
64 pytest7CheckHook
65 ] ++ optional-dependencies.all;
66
67 preCheck = ''
68 export PATH=$out/bin:$PATH
69 '';
70
71 meta = with lib; {
72 homepage = "https://nipy.org/nibabel";
73 changelog = "https://github.com/nipy/nibabel/blob/${version}/Changelog";
74 description = "Access a multitude of neuroimaging data formats";
75 license = licenses.mit;
76 maintainers = with maintainers; [ ashgillman ];
77 };
78}