diff --git a/var/spack/repos/builtin/packages/py-netcdf4/disable_parallel_support.patch b/var/spack/repos/builtin/packages/py-netcdf4/disable_parallel_support.patch new file mode 100644 index 00000000000..6c547dd3716 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-netcdf4/disable_parallel_support.patch @@ -0,0 +1,11 @@ +--- a/setup.py ++++ b/setup.py +@@ -392,7 +392,7 @@ + (netcdf_lib_version > "4.4" and netcdf_lib_version < "4.5"): + has_cdf5_format = True + +- has_parallel_support = check_has_parallel_support(inc_dirs) ++ has_parallel_support = False + has_has_not = "has" if has_parallel_support else "does not have" + print(f"netcdf lib {has_has_not} parallel functions") + diff --git a/var/spack/repos/builtin/packages/py-netcdf4/package.py b/var/spack/repos/builtin/packages/py-netcdf4/package.py index 3749b3ec139..94eb5e1f083 100644 --- a/var/spack/repos/builtin/packages/py-netcdf4/package.py +++ b/var/spack/repos/builtin/packages/py-netcdf4/package.py @@ -44,12 +44,19 @@ class PyNetcdf4(PythonPackage): # https://github.com/Unidata/netcdf4-python/pull/1317 depends_on("py-numpy@:1", when="@:1.6", type=("build", "link", "run")) depends_on("py-mpi4py", when="+mpi", type=("build", "run")) - # These forced variant requests are due to py-netcdf4 build scripts - # https://github.com/spack/spack/pull/47824#discussion_r1882473998 - depends_on("netcdf-c~mpi", when="~mpi") - depends_on("netcdf-c+mpi", when="+mpi") - depends_on("hdf5@1.8.0:+hl~mpi", when="~mpi") - depends_on("hdf5@1.8.0:+hl+mpi", when="+mpi") + + depends_on("netcdf-c") + depends_on("hdf5") + with when("@:1.6~mpi"): + # These forced variant requests are due to py-netcdf4 build scripts + # https://github.com/spack/spack/pull/47824#discussion_r1882473998 + depends_on("netcdf-c~mpi") + depends_on("hdf5~mpi") + with when("+mpi"): + depends_on("netcdf-c+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 # version of hdf5 installed with Spack does not have pkg-config files. @@ -58,6 +65,14 @@ class PyNetcdf4(PythonPackage): # following patch disables the usage of pkg-config at all. patch("disable_pkgconf.patch") + # Allow building py-netcdf4 ~mpi when netCDF was build with +mpi. This patch + # overrides the auto-decect feature (has_parallel_support) in setup.py. The + # logic in setup.py changed between 1.6 and 1.7, therefore this patch only + # works for versions 1.7.0 and later. + # See also: https://github.com/Unidata/netcdf4-python/issues/1389 + with when("@1.7:~mpi"): + patch("disable_parallel_support.patch", when="^netcdf-c+mpi") + # https://github.com/Unidata/netcdf4-python/pull/1322 patch( "https://github.com/Unidata/netcdf4-python/commit/49dcd0b5bd25824c254770c0d41445133fc13a46.patch?full_index=1",