Skip to content

Commit ded2ed6

Browse files
committed
raise if netcdf-c is parallel OK but we don't have mpi4py
1 parent 1960f84 commit ded2ed6

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

setup.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99

1010

1111

12-
has_mpi4py = False
13-
try:
14-
import mpi4py
15-
has_mpi4py = True
16-
except ImportError:
17-
print(f"mpi4py is not installed. Parallel support will be off even if netcdf-c supports it.")
18-
1912
open_kwargs = {'encoding': 'utf-8'}
2013

2114

@@ -56,8 +49,6 @@ def check_ifnetcdf4(netcdf4_includedir):
5649

5750
def check_has_parallel_support(inc_dirs: list) -> bool:
5851
has_parallel_support = False
59-
if not has_mpi4py:
60-
return has_parallel_support
6152

6253
for d in inc_dirs:
6354
ncmetapath = os.path.join(d,'netcdf_meta.h')
@@ -408,6 +399,12 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
408399
print(f"netcdf lib {has_has_not} parallel functions")
409400

410401
if has_parallel_support:
402+
try:
403+
import mpi4py
404+
except ImportError:
405+
msg = "Parallel support requires mpi4py but it is not installed."
406+
raise ImportError(msg)
407+
411408
inc_dirs.append(mpi4py.get_include())
412409
# mpi_incdir should not be needed if using nc-config
413410
# (should be included in nc-config --cflags)

0 commit comments

Comments
 (0)