summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/nibabel/default.nix
blob: 0873da577050a8ce24cbdbef4fa49207593448a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch2,
  pythonAtLeast,
  pythonOlder,

  # build-system
  hatch-vcs,
  hatchling,

  # dependencies
  numpy,
  packaging,
  importlib-resources,
  typing-extensions,

  # optional-dependencies
  pydicom,
  pillow,
  h5py,
  scipy,

  addBinToPathHook,
  gitMinimal,
  pytest-doctestplus,
  pytest-httpserver,
  pytest-xdist,
  pytest7CheckHook,
}:

buildPythonPackage (finalAttrs: {
  pname = "nibabel";
  version = "5.3.3";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "nipy";
    repo = "nibabel";
    tag = finalAttrs.version;
    hash = "sha256-Kdz7kCY5QnA9OiV/FPW1RerjP1GGLn+YaTwFpA0dJAM=";
  };

  patches = [
    (fetchpatch2 {
      url = "https://github.com/nipy/nibabel/commit/3f40a3bc0c4bd996734576a15785ad0f769a963a.patch?full_index=1";
      hash = "sha256-URsxgP6Sd5IIOX20GtAYtWBWOhw+Hiuhgu1oa8o8NXk=";
    })
  ];

  build-system = [
    hatch-vcs
    hatchling
  ];

  dependencies = [
    numpy
    packaging
  ]
  ++ lib.optionals (pythonOlder "3.12") [ importlib-resources ]
  ++ lib.optionals (pythonOlder "3.13") [ typing-extensions ];

  optional-dependencies = lib.fix (self: {
    all = self.dicom ++ self.dicomfs ++ self.minc2 ++ self.spm ++ self.zstd;
    dicom = [ pydicom ];
    dicomfs = [ pillow ] ++ self.dicom;
    minc2 = [ h5py ];
    spm = [ scipy ];
    zstd = [
      # TODO: pyzstd
    ];
  });

  nativeCheckInputs = [
    addBinToPathHook
    gitMinimal
    pytest-doctestplus
    pytest-httpserver
    pytest-xdist
    pytest7CheckHook
  ]
  ++ finalAttrs.passthru.optional-dependencies.all;

  disabledTests = lib.optionals (pythonAtLeast "3.14") [
    # https://github.com/nipy/nibabel/issues/1390
    "test_deprecator_maker"
  ];

  meta = {
    homepage = "https://nipy.org/nibabel";
    changelog = "https://github.com/nipy/nibabel/blob/${finalAttrs.version}/Changelog";
    description = "Access a multitude of neuroimaging data formats";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ ashgillman ];
  };
})