1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 cython,
6 jinja2,
7 numpy,
8 pyparsing,
9 setuptools,
10 sympy,
11 pytest,
12 pythonOlder,
13 pytest-xdist,
14 setuptools-scm,
15 python,
16 scipy,
17}:
18
19buildPythonPackage rec {
20 pname = "brian2";
21 version = "2.9.0";
22 pyproject = true;
23
24 # https://github.com/python/cpython/issues/117692
25 disabled = pythonOlder "3.12";
26
27 src = fetchPypi {
28 inherit pname version;
29 hash = "sha256-5N3uwcwj83VC49BnrOoncGI8Jk+97RRMptehtsw8o5c=";
30 };
31
32 patches = [
33 ./0001-remove-invalidxyz.patch # invalidxyz are reported as error so I remove it
34 ];
35
36 postPatch = ''
37 substituteInPlace pyproject.toml \
38 --replace-fail "numpy>=2.0.0rc1" "numpy"
39
40 substituteInPlace brian2/codegen/cpp_prefs.py \
41 --replace-fail "distutils" "setuptools._distutils"
42 '';
43
44 build-system = [
45 setuptools-scm
46 ];
47
48 dependencies = [
49 cython
50 jinja2
51 numpy
52 pyparsing
53 setuptools
54 sympy
55 scipy
56 ];
57
58 nativeCheckInputs = [
59 pytest
60 pytest-xdist
61 ];
62
63 checkPhase = ''
64 runHook preCheck
65 # Cython cache lies in home directory
66 export HOME=$(mktemp -d)
67 cd $HOME && ${python.interpreter} -c "import brian2;assert brian2.test()"
68 runHook postCheck
69 '';
70
71 meta = {
72 description = "Clock-driven simulator for spiking neural networks";
73 homepage = "https://briansimulator.org/";
74 license = lib.licenses.cecill21;
75 maintainers = with lib.maintainers; [ jiegec ];
76 };
77}