at master 2.5 kB view raw
1{ 2 lib, 3 fetchPypi, 4 buildPythonPackage, 5 pythonOlder, 6 setuptools, 7 numpy, 8 hdf5, 9 cython, 10 pkgconfig, 11 mpi4py ? null, 12 openssh, 13 pytestCheckHook, 14 pytest-mpi, 15 cached-property, 16}: 17 18assert hdf5.mpiSupport -> mpi4py != null && hdf5.mpi == mpi4py.mpi; 19 20let 21 mpi = hdf5.mpi; 22 mpiSupport = hdf5.mpiSupport; 23in 24buildPythonPackage rec { 25 version = "3.14.0"; 26 pname = "h5py"; 27 pyproject = true; 28 29 disabled = pythonOlder "3.7"; 30 31 src = fetchPypi { 32 inherit pname version; 33 hash = "sha256-I3IRay4NXT5ecFt/Zj98jZb6eaQFLSUEhO+R0k1qCPQ="; 34 }; 35 36 pythonRelaxDeps = [ "mpi4py" ]; 37 38 # Avoid strict pinning of Numpy, can't be replaced with pythonRelaxDepsHook, 39 # as these are build time dependencies. See: 40 # https://github.com/NixOS/nixpkgs/issues/327941 41 postPatch = '' 42 substituteInPlace pyproject.toml \ 43 --replace-fail "numpy >=2.0.0, <3" "numpy" 44 ''; 45 46 env = { 47 HDF5_DIR = "${hdf5}"; 48 HDF5_MPI = if mpiSupport then "ON" else "OFF"; 49 # See discussion at https://github.com/h5py/h5py/issues/2560 50 H5PY_SETUP_REQUIRES = 0; 51 }; 52 53 postConfigure = '' 54 # Needed to run the tests reliably. See: 55 # https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30 56 ${lib.optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"} 57 ''; 58 59 preBuild = lib.optionalString mpiSupport "export CC=${lib.getDev mpi}/bin/mpicc"; 60 61 build-system = [ 62 cython 63 numpy 64 pkgconfig 65 setuptools 66 ]; 67 68 buildInputs = [ hdf5 ] ++ lib.optional mpiSupport mpi; 69 70 dependencies = [ 71 numpy 72 ] 73 ++ lib.optionals mpiSupport [ 74 mpi4py 75 openssh 76 ] 77 ++ lib.optionals (pythonOlder "3.8") [ cached-property ]; 78 79 nativeCheckInputs = [ 80 pytestCheckHook 81 pytest-mpi 82 openssh 83 ]; 84 # https://github.com/NixOS/nixpkgs/issues/255262 85 preCheck = '' 86 cd $out 87 ''; 88 # For some reason these fail when mpi support is enabled, due to concurrent 89 # writings. There are a few open issues about this in the bug tracker, but 90 # not related to the tests. 91 disabledTests = lib.optionals mpiSupport [ "TestPageBuffering" ]; 92 93 pythonImportsCheck = [ "h5py" ]; 94 95 meta = { 96 changelog = "https://github.com/h5py/h5py/blob/${version}/docs/whatsnew/${lib.versions.majorMinor version}.rst"; 97 description = "Pythonic interface to the HDF5 binary data format"; 98 homepage = "http://www.h5py.org/"; 99 license = lib.licenses.bsd3; 100 maintainers = with lib.maintainers; [ doronbehar ]; 101 }; 102}