2022-11-27 09:42:12 +00:00
|
|
|
{ lib
|
|
|
|
, fetchPypi
|
|
|
|
, buildPythonPackage
|
|
|
|
, pythonOlder
|
|
|
|
, setuptools
|
|
|
|
, numpy
|
|
|
|
, hdf5
|
|
|
|
, cython
|
|
|
|
, pkgconfig
|
|
|
|
, mpi4py ? null
|
|
|
|
, openssh
|
|
|
|
, pytestCheckHook
|
|
|
|
, cached-property
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
assert hdf5.mpiSupport -> mpi4py != null && hdf5.mpi == mpi4py.mpi;
|
|
|
|
|
|
|
|
let
|
|
|
|
mpi = hdf5.mpi;
|
|
|
|
mpiSupport = hdf5.mpiSupport;
|
|
|
|
in buildPythonPackage rec {
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "3.7.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "h5py";
|
2022-11-27 09:42:12 +00:00
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-P883iEODxdpkhGq1EBkHIAJ9ygdo3vNN2Ny2Wdvly/M=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
# avoid strict pinning of numpy
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
2022-02-10 20:34:41 +00:00
|
|
|
--replace "numpy ==" "numpy >=" \
|
|
|
|
--replace "mpi4py ==" "mpi4py >="
|
2020-12-07 07:45:13 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
HDF5_DIR = "${hdf5}";
|
|
|
|
HDF5_MPI = if mpiSupport then "ON" else "OFF";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
postConfigure = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# Needed to run the tests reliably. See:
|
|
|
|
# https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30
|
2021-02-05 17:12:51 +00:00
|
|
|
${lib.optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
|
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cython
|
|
|
|
pkgconfig
|
|
|
|
setuptools
|
|
|
|
];
|
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
buildInputs = [ hdf5 ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optional mpiSupport mpi;
|
2022-11-27 09:42:12 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ numpy ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals mpiSupport [ mpi4py openssh ]
|
|
|
|
++ lib.optionals (pythonOlder "3.8") [ cached-property ];
|
2020-12-07 07:45:13 +00:00
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
# tests now require pytest-mpi, which isn't available and difficult to package
|
|
|
|
doCheck = false;
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook openssh ];
|
2022-11-27 09:42:12 +00:00
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
pythonImportsCheck = [ "h5py" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Pythonic interface to the HDF5 binary data format";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://www.h5py.org/";
|
2021-04-12 18:23:04 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|