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