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