summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/mne/default.nix
blob: b967acbe362c8e2f06e2c878f4f4359810ef65dd (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  pythonAtLeast,
  hatchling,
  hatch-vcs,
  numpy,
  scipy,
  flaky,
  pandas,
  pytestCheckHook,
  pytest-cov-stub,
  pytest-timeout,
  writableTmpDirAsHomeHook,
  matplotlib,
  decorator,
  jinja2,
  pooch,
  tqdm,
  packaging,
  lazy-loader,
  h5io,
  pymatreader,
  procps,
  optipng,
}:

buildPythonPackage rec {
  pname = "mne";
  version = "1.11.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "mne-tools";
    repo = "mne-python";
    tag = "v${version}";
    hash = "sha256-lssSHlWUj3TU0F/31jTFc+oFdBx1C+9aolee6M8mJtw=";
  };

  postPatch = ''
    substituteInPlace doc/conf.py \
      --replace-fail '"optipng"' '"${lib.getExe optipng}"'
    substituteInPlace mne/utils/config.py \
      --replace-fail '"free"'   '"${lib.getExe' procps "free"}"' \
      --replace-fail '"sysctl"' '"${lib.getExe' procps "sysctl"}"'
  '';

  build-system = [
    hatchling
    hatch-vcs
  ];

  dependencies = [
    numpy
    scipy
    matplotlib
    tqdm
    pooch
    decorator
    packaging
    jinja2
    lazy-loader
  ];

  optional-dependencies.hdf5 = [
    h5io
    pymatreader
  ];

  nativeCheckInputs = [
    flaky
    pandas
    pytestCheckHook
    pytest-cov-stub
    pytest-timeout
    writableTmpDirAsHomeHook
  ]
  ++ lib.concatAttrValues optional-dependencies;

  preCheck = ''
    export MNE_SKIP_TESTING_DATASET_TESTS=true
    export MNE_SKIP_NETWORK_TESTS=1
  '';

  disabledTests = [
    # requires qtbot which is unmaintained/not in Nixpkgs:
    "test_plotting_scalebars"
    # tries to write a datetime object to hdf5, which fails:
    "test_hitachi_basic"
    # flaky
    "test_fine_cal_systems"
    "test_simulate_raw_bem"
  ]
  ++ lib.optionals (pythonAtLeast "3.14") [
    #https://github.com/mne-tools/mne-python/issues/13577
    "test_set_montage_artinis_basic"
  ];

  pytestFlag = [
    # removes 700k lines from pytest log, remove this when scipy is at v1.17.0
    "--disable-warnings"
  ];

  disabledTestMarks = [
    "slowtest"
    "ultraslowtest"
    "pgtest"
  ];

  pythonImportsCheck = [ "mne" ];

  meta = {
    description = "Magnetoencephelography and electroencephalography in Python";
    mainProgram = "mne";
    homepage = "https://mne.tools";
    changelog = "https://mne.tools/stable/changes/v${lib.versions.majorMinor version}.html";
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [
      bcdarwin
    ];
  };
}