1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 pythonAtLeast,
6 pythonOlder,
7 hatchling,
8 hatch-vcs,
9 numpy,
10 packaging,
11 importlib-resources,
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.2.1";
26 pyproject = true;
27
28 disabled = pythonOlder "3.8";
29
30 src = fetchPypi {
31 inherit pname version;
32 hash = "sha256-tsgLLnKOS8K2XxFC2bjSKHqRAqi/hHfhFe8NgzRVmXU=";
33 };
34
35 nativeBuildInputs = [
36 hatchling
37 hatch-vcs
38 ];
39
40 propagatedBuildInputs = [
41 numpy
42 packaging
43 ] ++ lib.optionals (pythonOlder "3.9") [ importlib-resources ];
44
45 passthru.optional-dependencies = rec {
46 all = dicom ++ dicomfs ++ minc2 ++ spm ++ zstd;
47 dicom = [ pydicom ];
48 dicomfs = [ pillow ] ++ dicom;
49 minc2 = [ h5py ];
50 spm = [ scipy ];
51 zstd = [
52 # TODO: pyzstd
53 ];
54 };
55
56 nativeCheckInputs = [
57 git
58 pytest-doctestplus
59 pytest-httpserver
60 pytest-xdist
61 pytest7CheckHook
62 ] ++ passthru.optional-dependencies.all;
63
64 preCheck = ''
65 export PATH=$out/bin:$PATH
66 '';
67
68 disabledTestPaths = lib.optionals (pythonAtLeast "3.12") [
69 # uses distutils
70 "nisext/tests/test_sexts.py"
71 ];
72
73 meta = with lib; {
74 homepage = "https://nipy.org/nibabel";
75 changelog = "https://github.com/nipy/nibabel/blob/${version}/Changelog";
76 description = "Access a multitude of neuroimaging data formats";
77 license = licenses.mit;
78 maintainers = with maintainers; [ ashgillman ];
79 };
80}