Skip to content

Commit 3c127f1

Browse files
committed
Check if mpicc is available when CC is not set
1 parent 0ebef8a commit 3c127f1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@
1414
import mpi4py
1515
import json
1616
from packaging import version
17+
import shutil
1718

1819
open_kwargs = {'encoding': 'utf-8'}
1920

21+
if 'CC' not in os.environ:
22+
# environment variable CC is not set
23+
# check if command 'mpicc' is available in PATH
24+
path = shutil.which("mpicc")
25+
if path is None:
26+
raise RuntimeError("Error: could not find an mpicc, please set it in environment variable CC")
27+
os.environ["CC"] = path
28+
2029
PnetCDF_dir = os.environ.get('PNETCDF_DIR')
2130
pnc_config = None
2231

23-
2432
try:
2533
if pnc_config is None:
2634
if PnetCDF_dir is not None:

0 commit comments

Comments
 (0)