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