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