1{ stdenv, fetchPypi, isPy27, python, buildPythonPackage
2, numpy, hdf5, cython, six, pkgconfig, unittest2, fetchpatch
3, mpi4py ? null, openssh }:
4
5assert hdf5.mpiSupport -> mpi4py != null && hdf5.mpi == mpi4py.mpi;
6
7with stdenv.lib;
8
9let
10 mpi = hdf5.mpi;
11 mpiSupport = hdf5.mpiSupport;
12in buildPythonPackage rec {
13 version = "2.9.0";
14 pname = "h5py";
15
16 src = fetchPypi {
17 inherit pname version;
18 sha256 = "9d41ca62daf36d6b6515ab8765e4c8c4388ee18e2a665701fef2b41563821002";
19 };
20
21 patches = [ ( fetchpatch {
22 # Skip a test that probes an already fixed bug in HDF5 (upstream patch)
23 url = "https://github.com/h5py/h5py/commit/141eafa531c6c09a06efe6a694251a1eea84908d.patch";
24 sha256 = "0lmdn0gznr7gadx7qkxybl945fvwk6r0cc4lg3ylpf8ril1975h8";
25 })];
26
27 configure_flags = "--hdf5=${hdf5}" + optionalString mpiSupport " --mpi";
28
29 postConfigure = ''
30 ${python.executable} setup.py configure ${configure_flags}
31
32 # Needed to run the tests reliably. See:
33 # https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30
34 ${optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"}
35 '';
36
37 preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
38
39 checkInputs = optional isPy27 unittest2 ++ [ openssh ];
40 nativeBuildInputs = [ pkgconfig ];
41 buildInputs = [ hdf5 cython ]
42 ++ optional mpiSupport mpi;
43 propagatedBuildInputs = [ numpy six]
44 ++ optionals mpiSupport [ mpi4py openssh ];
45
46 meta = {
47 description =
48 "Pythonic interface to the HDF5 binary data format";
49 homepage = http://www.h5py.org/;
50 license = stdenv.lib.licenses.bsd2;
51 };
52}