1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9 setuptools-scm,
10
11 # dependencies
12 anytree,
13 cgen,
14 cloudpickle,
15 codepy,
16 llvmPackages,
17 multidict,
18 numpy,
19 packaging,
20 psutil,
21 py-cpuinfo,
22 sympy,
23
24 # tests
25 click,
26 gcc,
27 matplotlib,
28 pytest-xdist,
29 pytestCheckHook,
30 scipy,
31}:
32
33buildPythonPackage rec {
34 pname = "devito";
35 version = "4.8.19";
36 pyproject = true;
37
38 src = fetchFromGitHub {
39 owner = "devitocodes";
40 repo = "devito";
41 tag = "v${version}";
42 hash = "sha256-kE4u5r2GFe4Y+IdSEnNZEOAO9WoSIM00Ify1eLaflWI=";
43 };
44
45 pythonRemoveDeps = [ "pip" ];
46
47 pythonRelaxDeps = true;
48
49 build-system = [
50 setuptools
51 setuptools-scm
52 ];
53
54 dependencies = [
55 anytree
56 cgen
57 cloudpickle
58 codepy
59 multidict
60 numpy
61 packaging
62 psutil
63 py-cpuinfo
64 sympy
65 ]
66 ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
67
68 nativeCheckInputs = [
69 click
70 gcc
71 matplotlib
72 pytest-xdist
73 pytestCheckHook
74 scipy
75 ];
76
77 pytestFlags = [
78 "-x"
79 ];
80
81 disabledTestMarks = [
82 # Tests marked as 'parallel' require mpi and fail in the sandbox:
83 # FileNotFoundError: [Errno 2] No such file or directory: 'mpiexec'
84 "parallel"
85 ];
86
87 disabledTests = [
88 # Download dataset from the internet
89 "test_gs_2d_float"
90 "test_gs_2d_int"
91 ]
92 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
93 # FAILED tests/test_unexpansion.py::Test2Pass::test_v0 - assert False
94 "test_v0"
95 ]
96 ++ lib.optionals stdenv.hostPlatform.isDarwin [
97 # FAILED tests/test_caching.py::TestCaching::test_special_symbols - ValueError: not enough values to unpack (expected 3, got 2)
98 "test_special_symbols"
99
100 # FAILED tests/test_unexpansion.py::Test2Pass::test_v0 - codepy.CompileError: module compilation failed
101 "test_v0"
102
103 # AssertionError: assert(np.allclose(grad_u.data, grad_v.data, rtol=tolerance, atol=tolerance))
104 "test_gradient_equivalence"
105 ]
106 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
107 # Numerical tests
108 "test_lm_fb"
109 "test_lm_ds"
110 ]
111 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
112 # Numerical error
113 "test_pow_precision"
114 ];
115
116 disabledTestPaths =
117 lib.optionals
118 ((stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) || stdenv.hostPlatform.isDarwin)
119 [
120 # Flaky: codepy.CompileError: module compilation failed
121 "tests/test_dse.py"
122 ]
123 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
124 # assert np.all(f.data == check)
125 # assert Data(False)
126 "tests/test_data.py::TestDataReference::test_w_data"
127
128 # AssertionError: assert 'omp for schedule(dynamic,1)' == 'omp for coll...le(dynamic,1)'
129 "tests/test_dle.py::TestNestedParallelism::test_nested_cache_blocking_structure_subdims"
130
131 # codepy.CompileError: module compilation failed
132 # FAILED compiler invocation
133 "tests/test_dle.py::TestNodeParallelism::test_dynamic_nthreads"
134
135 # AssertionError: assert all(not i.pragmas for i in iters[2:])
136 "tests/test_dle.py::TestNodeParallelism::test_incr_perfect_sparse_outer"
137 ]
138 ++ lib.optionals stdenv.hostPlatform.isDarwin [
139 # IndexError: tuple index out of range
140 "tests/test_dle.py::TestNestedParallelism"
141
142 # codepy.CompileError: module compilation failed
143 "tests/test_autotuner.py::test_nested_nthreads"
144
145 # assert np.all(np.isclose(f0.data, check0))
146 # assert Data(false)
147 "tests/test_interpolation.py::TestSubDomainInterpolation::test_inject_subdomain"
148 ];
149
150 pythonImportsCheck = [ "devito" ];
151
152 meta = {
153 description = "Code generation framework for automated finite difference computation";
154 homepage = "https://www.devitoproject.org/";
155 changelog = "https://github.com/devitocodes/devito/releases/tag/v${version}";
156 license = lib.licenses.mit;
157 maintainers = with lib.maintainers; [ atila ];
158 };
159}