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.17";
36 pyproject = true;
37
38 src = fetchFromGitHub {
39 owner = "devitocodes";
40 repo = "devito";
41 tag = "v${version}";
42 hash = "sha256-1aZSL23yNi/X9hnYKpIvgEOjEZtvPgTo5Pi5kKOWJhQ=";
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 ] ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
66
67 nativeCheckInputs = [
68 click
69 gcc
70 matplotlib
71 pytest-xdist
72 pytestCheckHook
73 scipy
74 ];
75
76 pytestFlagsArray =
77 [
78 "-x"
79 # Tests marked as 'parallel' require mpi and fail in the sandbox:
80 # FileNotFoundError: [Errno 2] No such file or directory: 'mpiexec'
81 "-m 'not parallel'"
82 ]
83 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
84 # assert np.all(f.data == check)
85 # assert Data(False)
86 "--deselect tests/test_data.py::TestDataReference::test_w_data"
87
88 # AssertionError: assert 'omp for schedule(dynamic,1)' == 'omp for coll...le(dynamic,1)'
89 "--deselect tests/test_dle.py::TestNestedParallelism::test_nested_cache_blocking_structure_subdims"
90
91 # codepy.CompileError: module compilation failed
92 # FAILED compiler invocation
93 "--deselect tests/test_dle.py::TestNodeParallelism::test_dynamic_nthreads"
94
95 # AssertionError: assert all(not i.pragmas for i in iters[2:])
96 "--deselect tests/test_dle.py::TestNodeParallelism::test_incr_perfect_sparse_outer"
97 ]
98 ++ lib.optionals stdenv.hostPlatform.isDarwin [
99 # IndexError: tuple index out of range
100 "--deselect tests/test_dle.py::TestNestedParallelism"
101
102 # codepy.CompileError: module compilation failed
103 "--deselect tests/test_autotuner.py::test_nested_nthreads"
104
105 # assert np.all(np.isclose(f0.data, check0))
106 # assert Data(false)
107 "--deselect tests/test_interpolation.py::TestSubDomainInterpolation::test_inject_subdomain"
108 ];
109
110 disabledTests =
111 [
112 # Download dataset from the internet
113 "test_gs_2d_float"
114 "test_gs_2d_int"
115 ]
116 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
117 # FAILED tests/test_unexpansion.py::Test2Pass::test_v0 - assert False
118 "test_v0"
119 ]
120 ++ lib.optionals stdenv.hostPlatform.isDarwin [
121 # FAILED tests/test_caching.py::TestCaching::test_special_symbols - ValueError: not enough values to unpack (expected 3, got 2)
122 "test_special_symbols"
123
124 # FAILED tests/test_unexpansion.py::Test2Pass::test_v0 - codepy.CompileError: module compilation failed
125 "test_v0"
126
127 # AssertionError: assert(np.allclose(grad_u.data, grad_v.data, rtol=tolerance, atol=tolerance))
128 "test_gradient_equivalence"
129 ]
130 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
131 # Numerical tests
132 "test_lm_fb"
133 "test_lm_ds"
134 ]
135 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
136 # Numerical error
137 "test_pow_precision"
138 ];
139
140 disabledTestPaths =
141 lib.optionals
142 ((stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) || stdenv.hostPlatform.isDarwin)
143 [
144 # Flaky: codepy.CompileError: module compilation failed
145 "tests/test_dse.py"
146 ];
147
148 pythonImportsCheck = [ "devito" ];
149
150 meta = {
151 description = "Code generation framework for automated finite difference computation";
152 homepage = "https://www.devitoproject.org/";
153 changelog = "https://github.com/devitocodes/devito/releases/tag/v${version}";
154 license = lib.licenses.mit;
155 maintainers = with lib.maintainers; [ atila ];
156 };
157}