1{ lib, fetchPypi, isPy27, buildPythonPackage, pythonOlder
2, numpy, hdf5, cython, six, pkgconfig, unittest2
3, mpi4py ? null, openssh, pytestCheckHook, cached-property }:
4
5assert hdf5.mpiSupport -> mpi4py != null && hdf5.mpi == mpi4py.mpi;
6
7let
8 mpi = hdf5.mpi;
9 mpiSupport = hdf5.mpiSupport;
10in buildPythonPackage rec {
11 version = "3.4.0";
12 pname = "h5py";
13 disabled = isPy27;
14
15 src = fetchPypi {
16 inherit pname version;
17 sha256 = "ee1c683d91ab010d5e85cb61e8f9e7ee0d8eab545bf3dd50a9618f1d0e8f615e";
18 };
19
20 # avoid strict pinning of numpy
21 postPatch = ''
22 substituteInPlace setup.py \
23 --replace "numpy ==" "numpy >="
24 '';
25
26 HDF5_DIR = "${hdf5}";
27 HDF5_MPI = if mpiSupport then "ON" else "OFF";
28
29 postConfigure = ''
30 # Needed to run the tests reliably. See:
31 # https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30
32 ${lib.optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"}
33 '';
34
35 preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
36
37 # tests now require pytest-mpi, which isn't available and difficult to package
38 doCheck = false;
39 checkInputs = lib.optional isPy27 unittest2 ++ [ pytestCheckHook openssh ];
40 nativeBuildInputs = [ pkgconfig cython ];
41 buildInputs = [ hdf5 ]
42 ++ lib.optional mpiSupport mpi;
43 propagatedBuildInputs = [ numpy six]
44 ++ lib.optionals mpiSupport [ mpi4py openssh ]
45 ++ lib.optionals (pythonOlder "3.8") [ cached-property ];
46
47 pythonImportsCheck = [ "h5py" ];
48
49 meta = with lib; {
50 description = "Pythonic interface to the HDF5 binary data format";
51 homepage = "http://www.h5py.org/";
52 license = licenses.bsd3;
53 maintainers = [ ];
54 };
55}