Skip to content

Commit e9ac545

Browse files
committed
Compute real path to mpiexec
Otherwise, in some situations, we get to /bin/mpiexec (which is a symlink to the real path) which makes OpenMPI fail; see: open-mpi/ompi#5613 closes #209
1 parent 9b0d1fa commit e9ac545

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

khiops/core/internals/runner.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,12 @@ def _initialize_mpi_command_args(self):
11461146
installation_method = _infer_khiops_installation_method()
11471147
# In Conda-based, but non-Conda environment, specify mpiexec path
11481148
if installation_method == "conda-based":
1149-
mpiexec_path = os.environ.get("KHIOPS_MPIEXEC_PATH") or os.path.join(
1150-
_infer_env_bin_dir_for_conda_based_installations(), "mpiexec"
1149+
# Python `os.path.realpath` resolves symlinks recursively, like GNU
1150+
# `readlink -f`; Python `os.readlink` does not
1151+
mpiexec_path = os.environ.get("KHIOPS_MPIEXEC_PATH") or os.path.realpath(
1152+
os.path.join(
1153+
_infer_env_bin_dir_for_conda_based_installations(), "mpiexec"
1154+
)
11511155
)
11521156
if platform.system() == "Windows" and not os.path.splitext(mpiexec_path):
11531157
mpiexec_path += ".exe"
@@ -1165,8 +1169,11 @@ def _initialize_mpi_command_args(self):
11651169
)
11661170
# In Conda or local installations, expect mpiexec in the PATH
11671171
else:
1168-
mpiexec_path = os.environ.get("KHIOPS_MPIEXEC_PATH") or shutil.which(
1169-
"mpiexec"
1172+
link_to_mpiexec = shutil.which("mpiexec")
1173+
mpiexec_path = (
1174+
os.environ.get("KHIOPS_MPIEXEC_PATH")
1175+
or link_to_mpiexec
1176+
and os.path.realpath(link_to_mpiexec)
11701177
)
11711178
# If mpiexec is not in the path, and the installation method is local,
11721179
# then try to load MPI environment module so that mpiexec is in the path

0 commit comments

Comments
 (0)