1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 hatchling,
6 hatch-vcs,
7 numpy,
8 scipy,
9 pytestCheckHook,
10 pytest-cov-stub,
11 pytest-timeout,
12 matplotlib,
13 decorator,
14 jinja2,
15 pooch,
16 tqdm,
17 packaging,
18 lazy-loader,
19 h5io,
20 pymatreader,
21 pythonOlder,
22 procps,
23 optipng,
24}:
25
26buildPythonPackage rec {
27 pname = "mne";
28 # https://github.com/mne-tools/mne-python/pull/13049 is required to build, it does not apply if fetchpatch'ed
29 stableVersion = "1.9.0";
30 version = "1.9.0-unstable-2025-05-01";
31 pyproject = true;
32
33 disabled = pythonOlder "3.9";
34
35 src = fetchFromGitHub {
36 owner = "mne-tools";
37 repo = "mne-python";
38 rev = "5df1721b488070e3b3928dface9dd0b8c39a3bef";
39 hash = "sha256-BCLejk0sVym+HRCfnTl5LTOGUMrQdxZbqhrCnIpzsvM=";
40 };
41
42 env.SETUPTOOLS_SCM_PRETEND_VERSION = stableVersion;
43
44 postPatch = ''
45 substituteInPlace doc/conf.py \
46 --replace-fail '"optipng"' '"${lib.getExe optipng}"'
47 substituteInPlace mne/utils/config.py \
48 --replace-fail '"free"' '"${lib.getExe' procps "free"}"' \
49 --replace-fail '"sysctl"' '"${lib.getExe' procps "sysctl"}"'
50 '';
51
52 build-system = [
53 hatchling
54 hatch-vcs
55 ];
56
57 dependencies = [
58 numpy
59 scipy
60 matplotlib
61 tqdm
62 pooch
63 decorator
64 packaging
65 jinja2
66 lazy-loader
67 ];
68
69 optional-dependencies.hdf5 = [
70 h5io
71 pymatreader
72 ];
73
74 nativeCheckInputs = [
75 pytestCheckHook
76 pytest-cov-stub
77 pytest-timeout
78 ] ++ lib.flatten (builtins.attrValues optional-dependencies);
79
80 preCheck = ''
81 export HOME=$(mktemp -d)
82 export MNE_SKIP_TESTING_DATASET_TESTS=true
83 export MNE_SKIP_NETWORK_TESTS=1
84 '';
85
86 disabledTests = [
87 # requires qtbot which is unmaintained/not in Nixpkgs:
88 "test_plotting_scalebars"
89 # tries to write a datetime object to hdf5, which fails:
90 "test_hitachi_basic"
91 # flaky
92 "test_fine_cal_systems"
93 "test_simulate_raw_bem"
94 ];
95
96 pytestFlagsArray = [
97 "-m 'not (slowtest or ultraslowtest or pgtest)'"
98 # removes 700k lines form pytest log, remove this when scipy is at v1.17.0
99 "--disable-warnings"
100 ];
101
102 pythonImportsCheck = [ "mne" ];
103
104 meta = with lib; {
105 description = "Magnetoencephelography and electroencephalography in Python";
106 mainProgram = "mne";
107 homepage = "https://mne.tools";
108 changelog = "https://mne.tools/stable/changes/${stableVersion}.html";
109 license = licenses.bsd3;
110 maintainers = with maintainers; [
111 bcdarwin
112 mbalatsko
113 ];
114 };
115}