1{ fetchurl, stdenv
2, cmake, netcdf, openjpeg, libpng, gfortran
3, enablePython ? false, pythonPackages
4, enablePosixThreads ? false
5, enableOpenMPThreads ? false}:
6with stdenv.lib;
7stdenv.mkDerivation rec {
8 name = "eccodes-${version}";
9 version = "2.10.0";
10
11 src = fetchurl {
12 url = "https://confluence.ecmwf.int/download/attachments/45757960/eccodes-${version}-Source.tar.gz";
13 sha256 = "1n429najxlq6y76wyx1mbw41b0l4prdhfmy4id9ni8zwm96cp8xy";
14 };
15
16 postPatch = ''
17 substituteInPlace cmake/FindOpenJPEG.cmake --replace openjpeg-2.1 ${openjpeg.incDir}
18 '';
19
20 nativeBuildInputs = [ cmake ];
21
22 buildInputs = [ netcdf
23 openjpeg
24 libpng
25 gfortran
26 ];
27 propagatedBuildInputs = optionals enablePython [
28 pythonPackages.python
29 pythonPackages.numpy
30 ];
31
32 cmakeFlags = [ "-DENABLE_PYTHON=${if enablePython then "ON" else "OFF"}"
33 "-DENABLE_PNG=ON"
34 "-DENABLE_ECCODES_THREADS=${if enablePosixThreads then "ON" else "OFF"}"
35 "-DENABLE_ECCODES_OMP_THREADS=${if enableOpenMPThreads then "ON" else "OFF"}"
36 ];
37
38 enableParallelBuilding = true;
39
40 doCheck = true;
41
42 # Only do tests that don't require downloading 120MB of testdata
43 checkPhase = stdenv.lib.optionalString (stdenv.isDarwin) ''
44 substituteInPlace "tests/include.sh" --replace "set -ea" "set -ea; export DYLD_LIBRARY_PATH=$(pwd)/lib"
45 '' + ''
46 ctest -R "eccodes_t_(definitions|calendar|unit_tests|md5|uerra|grib_2nd_order_numValues|julian)" -VV
47 '';
48
49 meta = {
50 homepage = https://confluence.ecmwf.int/display/ECC/;
51 license = licenses.asl20;
52 maintainers = with maintainers; [ knedlsepp ];
53 platforms = platforms.unix;
54 description = "ECMWF library for reading and writing GRIB, BUFR and GTS abbreviated header";
55 };
56}