Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / python-modules / h5py / default.nix
blob9e5921bb412d82a8b96377f3880e09eeb135b542
1 { lib, fetchPypi, isPy27, python, buildPythonPackage, pythonOlder
2 , numpy, hdf5, cython, six, pkgconfig, unittest2, fetchpatch
3 , mpi4py ? null, openssh, pytestCheckHook, cached-property }:
5 assert hdf5.mpiSupport -> mpi4py != null && hdf5.mpi == mpi4py.mpi;
7 let
8   mpi = hdf5.mpi;
9   mpiSupport = hdf5.mpiSupport;
10 in buildPythonPackage rec {
11   version = "3.2.1";
12   pname = "h5py";
13   disabled = isPy27;
15   src = fetchPypi {
16     inherit pname version;
17     sha256 = "sha256-iUdL6RG/zbNMvw2YuOxItXjCeon9sa5O51E/HvjZJJ4=";
18   };
20   # avoid strict pinning of numpy
21   postPatch = ''
22     substituteInPlace setup.py \
23       --replace "numpy ==" "numpy >="
24   '';
26   HDF5_DIR = "${hdf5}";
27   HDF5_MPI = if mpiSupport then "ON" else "OFF";
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   '';
35   preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
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 ];
47   pythonImportsCheck = [ "h5py" ];
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   };