Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 100 lines 2.4 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.12.1"; 26 pname = "h5py"; 27 pyproject = true; 28 29 disabled = pythonOlder "3.7"; 30 31 src = fetchPypi { 32 inherit pname version; 33 hash = "sha256-Mm1wtT0xuqYfALiqX5XC/LliGj7oNl13DFUaE9u8v98="; 34 }; 35 36 pythonRelaxDeps = [ "mpi4py" ]; 37 38 # avoid strict pinning of numpy and mpi4py, can't be replaced with 39 # pythonRelaxDepsHook, see: https://github.com/NixOS/nixpkgs/issues/327941 40 postPatch = '' 41 substituteInPlace pyproject.toml \ 42 --replace-fail "numpy >=2.0.0, <3" "numpy" 43 substituteInPlace setup.py \ 44 --replace-fail "mpi4py ==3.1.6" "mpi4py" 45 ''; 46 47 env = { 48 HDF5_DIR = "${hdf5}"; 49 HDF5_MPI = if mpiSupport then "ON" else "OFF"; 50 }; 51 52 postConfigure = '' 53 # Needed to run the tests reliably. See: 54 # https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30 55 ${lib.optionalString mpiSupport "export OMPI_MCA_rmaps_base_oversubscribe=yes"} 56 ''; 57 58 preBuild = lib.optionalString mpiSupport "export CC=${lib.getDev mpi}/bin/mpicc"; 59 60 build-system = [ 61 cython 62 numpy 63 pkgconfig 64 setuptools 65 ]; 66 67 buildInputs = [ hdf5 ] ++ lib.optional mpiSupport mpi; 68 69 dependencies = 70 [ numpy ] 71 ++ lib.optionals mpiSupport [ 72 mpi4py 73 openssh 74 ] 75 ++ lib.optionals (pythonOlder "3.8") [ cached-property ]; 76 77 nativeCheckInputs = [ 78 pytestCheckHook 79 pytest-mpi 80 openssh 81 ]; 82 # https://github.com/NixOS/nixpkgs/issues/255262 83 preCheck = '' 84 cd $out 85 ''; 86 # For some reason these fail when mpi support is enabled, due to concurrent 87 # writings. There are a few open issues about this in the bug tracker, but 88 # not related to the tests. 89 disabledTests = lib.optionals mpiSupport [ "TestPageBuffering" ]; 90 91 pythonImportsCheck = [ "h5py" ]; 92 93 meta = { 94 changelog = "https://github.com/h5py/h5py/blob/${version}/docs/whatsnew/${lib.versions.majorMinor version}.rst"; 95 description = "Pythonic interface to the HDF5 binary data format"; 96 homepage = "http://www.h5py.org/"; 97 license = lib.licenses.bsd3; 98 maintainers = with lib.maintainers; [ doronbehar ]; 99 }; 100}