Skip to content

Commit 17eb3e5

Browse files
committed
set has_parallel_support to False when mpi4py is not available
1 parent cd5e5fc commit 17eb3e5

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

setup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
from setuptools.dist import Distribution
88
from typing import List
99

10+
11+
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+
1019
open_kwargs = {'encoding': 'utf-8'}
1120

1221

@@ -47,6 +56,8 @@ def check_ifnetcdf4(netcdf4_includedir):
4756

4857
def check_has_parallel_support(inc_dirs: list) -> bool:
4958
has_parallel_support = False
59+
if not has_mpi4py:
60+
return has_parallel_support
5061

5162
for d in inc_dirs:
5263
ncmetapath = os.path.join(d,'netcdf_meta.h')
@@ -397,7 +408,6 @@ def _populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs):
397408
print(f"netcdf lib {has_has_not} parallel functions")
398409

399410
if has_parallel_support:
400-
import mpi4py
401411
inc_dirs.append(mpi4py.get_include())
402412
# mpi_incdir should not be needed if using nc-config
403413
# (should be included in nc-config --cflags)

0 commit comments

Comments
 (0)