py-netcdf4: enable non-MPI build per variant, even if netcdf-c was built with MPI (#48694)
* Add patch for py-netcdf4 so that we can build py-netcdf4 with ~mpi when netCDF was built with +mpi * Address reviewer requests for py-netcdf4. Add conflict for 'pynetcdf4~mpi ^netcdf-c~mpi ^hdf5+mpi' * Make py-netcdf4~mpi ^netcdf-c~mpi ^hdf5+mpi work * Apply suggestions from code review Co-authored-by: Sergey Kosukhin <skosukhin@gmail.com> * Update var/spack/repos/builtin/packages/py-netcdf4/disable_parallel_support.patch * Apply suggestions from code review Co-authored-by: Sergey Kosukhin <skosukhin@gmail.com> --------- Co-authored-by: Sergey Kosukhin <skosukhin@gmail.com>
This commit is contained in:
parent
87505fc2fc
commit
eaabde6ee9
@ -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")
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user