diff --git a/.travis.yml b/.travis.yml index 18debc2..b1a6f4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,6 +63,7 @@ addons: packages: - ibverbs-utils - libibverbs-dev + - realpath - wget - zsh diff --git a/mpienv/mpienv_init.py b/mpienv/mpienv_init.py index d4c2133..5a775f4 100644 --- a/mpienv/mpienv_init.py +++ b/mpienv/mpienv_init.py @@ -12,11 +12,11 @@ mkdir -p ${MPIENV_VERSIONS_DIR} -function usage() { +usage() { echo "Usage: mpienv [command] [options...]" } -function mpienv() { +mpienv() { if [ "0" = "${#*}" ]; then usage return -1 diff --git a/mpienv/py.py b/mpienv/py.py index 92e9a1c..3ea38f0 100644 --- a/mpienv/py.py +++ b/mpienv/py.py @@ -2,10 +2,11 @@ from __future__ import print_function import errno -import glob import os import os.path import shutil +from subprocess import PIPE +from subprocess import Popen import sys import mpienv.pip as pip @@ -35,8 +36,11 @@ def __init__(self, libname, conf, name): mkdir_p(self._pylib_dir) def is_installed(self): - libs = glob.glob(os.path.join(self._pylib_dir, self._libname, '*.so')) - return len(libs) > 0 + """Check if mpi4py is installed""" + python = sys.executable + p = Popen([python, '-c', 'import mpi4py'], stdout=PIPE, stderr=PIPE) + p.communicate() + return p.returncode == 0 def install(self, env): sys.stderr.write( diff --git a/tests/test_main.sh b/tests/test_main.sh index 412cfdf..9bc45b1 100755 --- a/tests/test_main.sh +++ b/tests/test_main.sh @@ -410,10 +410,10 @@ test_reg_issue10() { # https://github.com/keisukefukuda/mpienv/issues/10 assertSuccess mpienv autodiscover -q --add ${MPI_PREFIX} - mpienv use --mpi4py ${MPICH} # this command should install mpi4py to mpich-3.2 + mpienv use ${MPICH} # this command should install mpi4py to mpich-3.2 mpienv rename ${MPICH} mpix # The mpi4py module should be taken over to 'mpix' - OUT=$(mpienv use mpix 2>&1) # this command should NOT intall mpi4py again + OUT=$(mpienv use mpix 2>&1) # this command should NOT install mpi4py again # If the `use` command does not run `pip install mpi4py`, # which is a correct behavior, E-S should be < 1 [s]. @@ -434,7 +434,10 @@ test_reg_issue_timeout() { test_reg_issue_134_add_relpath() { # Regression test for pushd $HOME - OMPI_relpath=$(realpath --relative-to=$PWD $OMPI_ROOT) + echo realpath --version + realpath --version + # OMPI_relpath=$(realpath --relative-to $PWD $OMPI_ROOT) + OMPI_relpath=$(python -c "import os.path; print(os.path.relpath('${OMPI_ROOT}', '${PWD}'))") mpienv add ${OMPI_relpath} mpienv use ${OMPI} popd