Skip to content

Commit

Permalink
Merge pull request #502 from climbfuji/bugfix/pynetcdf4_nompi
Browse files Browse the repository at this point in the history
Add patch for py-netcdf4 so that we can build it ~mpi
  • Loading branch information
climbfuji authored Jan 21, 2025
2 parents afa5072 + 662935d commit 0ee54ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions var/spack/repos/builtin/packages/py-netcdf4/nompi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/setup.py
+++ b/setup.py
@@ -392,7 +392,8 @@ if 'sdist' not in sys.argv[1:] and 'clean' not in sys.argv[1:] and '--version' n
(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 = 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")
10 changes: 8 additions & 2 deletions var/spack/repos/builtin/packages/py-netcdf4/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ 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"))
depends_on("netcdf-c", when="-mpi")
depends_on("netcdf-c", when="~mpi")
depends_on("netcdf-c+mpi", when="+mpi")
depends_on("[email protected]:+hl", when="-mpi")
depends_on("[email protected]:+hl", when="~mpi")
depends_on("[email protected]:+hl+mpi", when="+mpi")

# The installation script tries to find hdf5 using pkg-config. However, the
Expand All @@ -54,6 +54,12 @@ 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.5 and 1.7.1, therefore this patch
# only works for versions 1.7.1 and later.
patch("nompi.patch", when="@1.7.1: ~mpi")

# https://github.com/Unidata/netcdf4-python/pull/1322
patch(
"https://github.com/Unidata/netcdf4-python/commit/49dcd0b5bd25824c254770c0d41445133fc13a46.patch?full_index=1",
Expand Down

0 comments on commit 0ee54ff

Please sign in to comment.