Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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 ]
79 ++ lib.flatten (builtins.attrValues optional-dependencies);
80
81 preCheck = ''
82 export HOME=$(mktemp -d)
83 export MNE_SKIP_TESTING_DATASET_TESTS=true
84 export MNE_SKIP_NETWORK_TESTS=1
85 '';
86
87 disabledTests = [
88 # requires qtbot which is unmaintained/not in Nixpkgs:
89 "test_plotting_scalebars"
90 # tries to write a datetime object to hdf5, which fails:
91 "test_hitachi_basic"
92 # flaky
93 "test_fine_cal_systems"
94 "test_simulate_raw_bem"
95 ];
96
97 pytestFlag = [
98 # removes 700k lines form pytest log, remove this when scipy is at v1.17.0
99 "--disable-warnings"
100 ];
101
102 disabledTestMarks = [
103 "slowtest"
104 "ultraslowtest"
105 "pgtest"
106 ];
107
108 pythonImportsCheck = [ "mne" ];
109
110 meta = with lib; {
111 description = "Magnetoencephelography and electroencephalography in Python";
112 mainProgram = "mne";
113 homepage = "https://mne.tools";
114 changelog = "https://mne.tools/stable/changes/${stableVersion}.html";
115 license = licenses.bsd3;
116 maintainers = with maintainers; [
117 bcdarwin
118 mbalatsko
119 ];
120 };
121}