py-netcdf4: enable non-MPI build agains MPI-enabled HDF5 (#50186)

This commit is contained in:
Sergey Kosukhin 2025-05-05 10:37:30 +02:00 committed by GitHub
parent 8e948c03fc
commit 3e3cb73446
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View File

@ -1,3 +1,27 @@
--- a/include/netCDF4.pxi
+++ b/include/netCDF4.pxi
@@ -4,8 +4,8 @@
ctypedef long ptrdiff_t
# hdf5 version info.
-cdef extern from "H5public.h":
- ctypedef int herr_t
+ctypedef int herr_t
+cdef extern \
int H5get_libversion( unsigned int *majnum, unsigned int *minnum, unsigned int *relnum ) nogil
cdef extern from *:
--- a/include/netcdf-compat.h
+++ b/include/netcdf-compat.h
@@ -95,7 +95,7 @@
#define HAS_CDF5_FORMAT 0
#endif
-#if defined(NC_HAS_PARALLEL) && NC_HAS_PARALLEL
+#if 0
#include <netcdf_par.h>
#define HAS_PARALLEL_SUPPORT 1
#else
--- a/setup.py --- a/setup.py
+++ b/setup.py +++ b/setup.py
@@ -392,7 +392,7 @@ @@ -392,7 +392,7 @@

View File

@ -55,8 +55,6 @@ class PyNetcdf4(PythonPackage):
with when("+mpi"): with when("+mpi"):
depends_on("netcdf-c+mpi") depends_on("netcdf-c+mpi")
depends_on("hdf5+mpi") depends_on("hdf5+mpi")
# We cannot build py-netcdf4~mpi ^netcdf-c~mpi ^hdf5+mpi
conflicts("hdf5+mpi", when="~mpi ^netcdf-c~mpi")
# The installation script tries to find hdf5 using pkg-config. However, the # The installation script tries to find hdf5 using pkg-config. However, the
# version of hdf5 installed with Spack does not have pkg-config files. # version of hdf5 installed with Spack does not have pkg-config files.
@ -72,6 +70,7 @@ class PyNetcdf4(PythonPackage):
# See also: https://github.com/Unidata/netcdf4-python/issues/1389 # See also: https://github.com/Unidata/netcdf4-python/issues/1389
with when("@1.7:~mpi"): with when("@1.7:~mpi"):
patch("disable_parallel_support.patch", when="^netcdf-c+mpi") patch("disable_parallel_support.patch", when="^netcdf-c+mpi")
patch("disable_parallel_support.patch", when="^hdf5+mpi")
# https://github.com/Unidata/netcdf4-python/pull/1322 # https://github.com/Unidata/netcdf4-python/pull/1322
patch( patch(