1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 blas,
7 boost,
8 cmake,
9 doxygen,
10 eigen,
11 gtest,
12 hdf5,
13 lapack,
14 mpi,
15 mpi4py,
16 numpy,
17 pkg-config,
18 ply,
19 pybind11,
20 pytest,
21 python,
22 pythonPackages,
23 scotch,
24 setuptools,
25 six,
26 sphinx,
27 suitesparse,
28 swig,
29 sympy,
30 zlib,
31 nixosTests,
32}:
33
34let
35 version = "2019.1.0";
36
37 dijitso = pythonPackages.buildPythonPackage {
38 pname = "dijitso";
39 inherit version;
40 src = fetchurl {
41 url = "https://bitbucket.org/fenics-project/dijitso/downloads/dijitso-${version}.tar.gz";
42 sha256 = "1ncgbr0bn5cvv16f13g722a0ipw6p9y6p4iasxjziwsp8kn5x97a";
43 };
44 propagatedBuildInputs = [
45 numpy
46 six
47 ];
48 nativeCheckInputs = [ pytest ];
49 preCheck = ''
50 export HOME=$PWD
51 '';
52 checkPhase = ''
53 runHook preCheck
54 py.test test/
55 runHook postCheck
56 '';
57 meta = {
58 description = "Distributed just-in-time shared library building";
59 homepage = "https://fenicsproject.org/";
60 platforms = lib.platforms.all;
61 license = lib.licenses.lgpl3;
62 };
63 };
64
65 fiat = pythonPackages.buildPythonPackage {
66 pname = "fiat";
67 inherit version;
68 src = fetchurl {
69 url = "https://bitbucket.org/fenics-project/fiat/downloads/fiat-${version}.tar.gz";
70 sha256 = "1sbi0fbr7w9g9ajr565g3njxrc3qydqjy3334vmz5xg0rd3106il";
71 };
72 propagatedBuildInputs = [
73 numpy
74 six
75 sympy
76 ];
77 nativeCheckInputs = [ pytest ];
78
79 preCheck = ''
80 # Workaround pytest 4.6.3 issue.
81 # See: https://bitbucket.org/fenics-project/fiat/pull-requests/59
82 rm test/unit/test_quadrature.py
83 rm test/unit/test_reference_element.py
84 rm test/unit/test_fiat.py
85
86 # Fix `np.float` deprecation in Numpy 1.20
87 grep -lr 'np.float(' test/ | while read -r fn; do
88 substituteInPlace "$fn" \
89 --replace "np.float(" "np.float64("
90 done
91 '';
92 checkPhase = ''
93 runHook preCheck
94 py.test test/unit/
95 runHook postCheck
96 '';
97 meta = {
98 description = "Automatic generation of finite element basis functions";
99 homepage = "https://fenicsproject.org/";
100 platforms = lib.platforms.all;
101 license = lib.licenses.lgpl3;
102 };
103 };
104
105 ufl = pythonPackages.buildPythonPackage {
106 pname = "ufl";
107 inherit version;
108 src = fetchurl {
109 url = "https://bitbucket.org/fenics-project/ufl/downloads/ufl-${version}.tar.gz";
110 sha256 = "04daxwg4y9c51sdgvwgmlc82nn0fjw7i2vzs15ckdc7dlazmcfi1";
111 };
112 propagatedBuildInputs = [
113 numpy
114 six
115 ];
116 nativeCheckInputs = [ pytest ];
117 checkPhase = ''
118 runHook preCheck
119 py.test test/
120 runHook postCheck
121 '';
122 meta = {
123 description = "Domain-specific language for finite element variational forms";
124 homepage = "https://fenicsproject.org/";
125 platforms = lib.platforms.all;
126 license = lib.licenses.lgpl3;
127 };
128 };
129
130 ffc = pythonPackages.buildPythonPackage {
131 pname = "ffc";
132 inherit version;
133 src = fetchurl {
134 url = "https://bitbucket.org/fenics-project/ffc/downloads/ffc-${version}.tar.gz";
135 sha256 = "1zdg6pziss4va74pd7jjl8sc3ya2gmhpypccmyd8p7c66ji23y2g";
136 };
137 nativeBuildInputs = [ pybind11 ];
138 propagatedBuildInputs = [
139 dijitso
140 fiat
141 numpy
142 six
143 sympy
144 ufl
145 setuptools
146 ];
147 nativeCheckInputs = [ pytest ];
148 preCheck = ''
149 export HOME=$PWD
150 rm test/unit/ufc/finite_element/test_evaluate.py
151 '';
152 checkPhase = ''
153 runHook preCheck
154 py.test test/unit/
155 runHook postCheck
156 '';
157 meta = {
158 description = "Compiler for finite element variational forms";
159 homepage = "https://fenicsproject.org/";
160 platforms = lib.platforms.all;
161 license = lib.licenses.lgpl3;
162 };
163 };
164 dolfin = stdenv.mkDerivation {
165 pname = "dolfin";
166 inherit version;
167 src = fetchurl {
168 url = "https://bitbucket.org/fenics-project/dolfin/downloads/dolfin-${version}.tar.gz";
169 sha256 = "0kbyi4x5f6j4zpasch0swh0ch81w2h92rqm1nfp3ydi4a93vky33";
170 };
171 patches = [
172 (fetchpatch {
173 name = "fix-double-prefix.patch";
174 url = "https://bitbucket.org/josef_kemetmueller/dolfin/commits/328e94acd426ebaf2243c072b806be3379fd4340/raw";
175 sha256 = "1zj7k3y7vsx0hz3gwwlxhq6gdqamqpcw90d4ishwx5ps5ckcsb9r";
176 })
177 (fetchpatch {
178 url = "https://bitbucket.org/fenics-project/dolfin/issues/attachments/1116/fenics-project/dolfin/1602778118.04/1116/0001-Use-__BYTE_ORDER__-instead-of-removed-Boost-endian.h.patch";
179 hash = "sha256-wPaDmPU+jaD3ce3nNEbvM5p8e3zBdLozamLTJ/0ai2c=";
180 })
181 ];
182 # https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=dolfin&id=a965ad934f7b3d49a5e77fa6fb5e3c710ec2163e
183 postPatch = ''
184 sed -i '20 a #include <algorithm>' dolfin/geometry/IntersectionConstruction.cpp
185 sed -i '26 a #include <algorithm>' dolfin/mesh/MeshFunction.h
186 sed -i '25 a #include <cstdint>' dolfin/mesh/MeshConnectivity.h
187 '';
188 propagatedBuildInputs = [
189 dijitso
190 fiat
191 numpy
192 six
193 ufl
194 ];
195 nativeBuildInputs = [
196 cmake
197 doxygen
198 pkg-config
199 ];
200 buildInputs = [
201 boost
202 dijitso
203 eigen
204 ffc
205 fiat
206 hdf5
207 mpi
208 numpy
209 blas
210 lapack
211 ply
212 python
213 scotch
214 six
215 sphinx
216 suitesparse
217 swig
218 sympy
219 ufl
220 zlib
221 ];
222 cmakeFlags = [
223 "-DDOLFIN_CXX_FLAGS=-std=c++11"
224 "-DDOLFIN_AUTO_DETECT_MPI=ON"
225 "-DDOLFIN_ENABLE_CHOLMOD=ON"
226 "-DDOLFIN_ENABLE_DOCS=ON"
227 "-DDOLFIN_ENABLE_HDF5=ON"
228 "-DDOLFIN_ENABLE_MPI=ON"
229 "-DDOLFIN_ENABLE_SCOTCH=ON"
230 "-DDOLFIN_ENABLE_UMFPACK=ON"
231 "-DDOLFIN_ENABLE_ZLIB=ON"
232 "-DDOLFIN_SKIP_BUILD_TESTS=ON" # Otherwise SCOTCH is not found
233 # TODO: Enable the following features
234 "-DDOLFIN_ENABLE_PARMETIS=OFF"
235 "-DDOLFIN_ENABLE_PETSC=OFF"
236 "-DDOLFIN_ENABLE_SLEPC=OFF"
237 "-DDOLFIN_ENABLE_TRILINOS=OFF"
238 ];
239 installCheckPhase = ''
240 source $out/share/dolfin/dolfin.conf
241 make runtests
242 '';
243 meta = {
244 description = "FEniCS Problem Solving Environment in Python and C++";
245 homepage = "https://fenicsproject.org/";
246 license = lib.licenses.lgpl3;
247 };
248 };
249 python-dolfin = pythonPackages.buildPythonPackage rec {
250 pname = "dolfin";
251 inherit version;
252 disabled = pythonPackages.isPy27;
253 src = dolfin.src;
254 sourceRoot = "${pname}-${version}/python";
255 nativeBuildInputs = [
256 pybind11
257 cmake
258 ];
259 dontUseCmakeConfigure = true;
260 preConfigure = ''
261 export CMAKE_PREFIX_PATH=${pybind11}/share/cmake/pybind11:$CMAKE_PREFIX_PATH
262 substituteInPlace setup.py --replace "pybind11==2.2.4" "pybind11"
263 substituteInPlace dolfin/jit/jit.py \
264 --replace 'pkgconfig.exists("dolfin")' 'pkgconfig.exists("${dolfin}/lib/pkgconfig/dolfin.pc")' \
265 --replace 'pkgconfig.parse("dolfin")' 'pkgconfig.parse("${dolfin}/lib/pkgconfig/dolfin.pc")'
266 '';
267 buildInputs = [
268 dolfin
269 boost
270 ];
271
272 propagatedBuildInputs = [
273 dijitso
274 ffc
275 mpi4py
276 numpy
277 ufl
278 pythonPackages.pkgconfig
279 pythonPackages.pybind11
280 ];
281 doCheck = false; # Tries to orte_ess_init and call ssh to localhost
282 passthru.tests = {
283 inherit (nixosTests) fenics;
284 };
285 meta = {
286 description = "Python bindings for the DOLFIN FEM compiler";
287 homepage = "https://fenicsproject.org/";
288 platforms = lib.platforms.all;
289 license = lib.licenses.lgpl3;
290 };
291 };
292in
293python-dolfin