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