Commit 612942fb authored by Martin Weinelt's avatar Martin Weinelt
Browse files
parent 85690131
Loading
Loading
Loading
Loading
+13 −21
Original line number Diff line number Diff line
{
  lib,
  fetchPypi,
  fetchpatch,
  buildPythonPackage,
  pythonOlder,
  setuptools,
  numpy,
  hdf5,
  cython_0,
  cython,
  pkgconfig,
  mpi4py ? null,
  openssh,
@@ -23,7 +22,7 @@ let
  mpiSupport = hdf5.mpiSupport;
in
buildPythonPackage rec {
  version = "3.11.0";
  version = "3.12.1";
  pname = "h5py";
  pyproject = true;

@@ -31,30 +30,22 @@ buildPythonPackage rec {

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-e36PeAcqLt7IfJg28l80ID/UkqRHVwmhi0F6M8+yH6k=";
    hash = "sha256-Mm1wtT0xuqYfALiqX5XC/LliGj7oNl13DFUaE9u8v98=";
  };

  patches = [
    # Unlock an overly strict locking of mpi4py version (seems not to be necessary).
    # See also: https://github.com/h5py/h5py/pull/2418/files#r1589372479
    ./mpi4py-requirement.patch
    # Fix 16-bit float dtype and tests on darwin (remove in next release)
    (fetchpatch {
      url = "https://github.com/h5py/h5py/commit/a27a1f49ce92d985e14b8a24fa80d30e5174add2.patch";
      hash = "sha256-7TcmNSJucknq+Vnv4ViT6S0nWeH1+krarWxq6WXLYEA=";
    })
  ];
  pythonRelaxDeps = [ "mpi4py" ];

  # avoid strict pinning of numpy, can't be replaced with pythonRelaxDepsHook,
  # see: https://github.com/NixOS/nixpkgs/issues/327941
  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "numpy >=2.0.0rc1" "numpy"
      --replace-fail "numpy >=2.0.0, <3" "numpy"
  '';
  pythonRelaxDeps = [ "mpi4py" ];

  env = {
    HDF5_DIR = "${hdf5}";
    HDF5_MPI = if mpiSupport then "ON" else "OFF";
  };

  postConfigure = ''
    # Needed to run the tests reliably. See:
@@ -64,15 +55,16 @@ buildPythonPackage rec {

  preBuild = lib.optionalString mpiSupport "export CC=${lib.getDev mpi}/bin/mpicc";

  nativeBuildInputs = [
    cython_0
  build-system = [
    cython
    numpy
    pkgconfig
    setuptools
  ];

  buildInputs = [ hdf5 ] ++ lib.optional mpiSupport mpi;

  propagatedBuildInputs =
  dependencies =
    [ numpy ]
    ++ lib.optionals mpiSupport [
      mpi4py