1{ lib
2, fetchPypi
3, buildPythonPackage
4, pythonOlder
5, setuptools
6, numpy
7, hdf5
8, cython
9, pkgconfig
10, mpi4py ? null
11, openssh
12, pytestCheckHook
13, cached-property
14}:
15
16assert hdf5.mpiSupport -> mpi4py != null && hdf5.mpi == mpi4py.mpi;
17
18let
19 mpi = hdf5.mpi;
20 mpiSupport = hdf5.mpiSupport;
21in buildPythonPackage rec {
22 version = "3.8.0";
23 pname = "h5py";
24 format = "pyproject";
25
26 disabled = pythonOlder "3.7";
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-b+rYLwxAAM841T+cAweA2Bv6AiAhiu4TuQt3Ack32V8=";
31 };
32
33 # avoid strict pinning of numpy
34 postPatch = ''
35 substituteInPlace setup.py \
36 --replace "numpy ==" "numpy >=" \
37 --replace "mpi4py ==" "mpi4py >="
38 '';
39
40 HDF5_DIR = "${hdf5}";
41 HDF5_MPI = if mpiSupport then "ON" else "OFF";
42
43 postConfigure = ''
44 # Needed to run the tests reliably. See:
45 # https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30
46 ${lib.optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"}
47 '';
48
49 preBuild = lib.optionalString mpiSupport "export CC=${mpi}/bin/mpicc";
50
51 nativeBuildInputs = [
52 cython
53 pkgconfig
54 setuptools
55 ];
56
57 buildInputs = [ hdf5 ]
58 ++ lib.optional mpiSupport mpi;
59
60 propagatedBuildInputs = [ numpy ]
61 ++ lib.optionals mpiSupport [ mpi4py openssh ]
62 ++ lib.optionals (pythonOlder "3.8") [ cached-property ];
63
64 # tests now require pytest-mpi, which isn't available and difficult to package
65 doCheck = false;
66 nativeCheckInputs = [ pytestCheckHook openssh ];
67
68 pythonImportsCheck = [ "h5py" ];
69
70 meta = with lib; {
71 changelog = "https://github.com/h5py/h5py/blob/${version}/docs/whatsnew/${lib.versions.majorMinor version}.rst";
72 description = "Pythonic interface to the HDF5 binary data format";
73 homepage = "http://www.h5py.org/";
74 license = licenses.bsd3;
75 maintainers = [ ];
76 };
77}