Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #97 from keisukefukuda/pip-installable
Browse files Browse the repository at this point in the history
pip-installable
  • Loading branch information
keisukefukuda committed Sep 5, 2018
2 parents f675474 + b3a8488 commit 04ec11e
Show file tree
Hide file tree
Showing 22 changed files with 318 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ versions
shims
*.pyc
pylib

dist
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ sudo: false

dist: trusty

cache:
directories:
- /home/travis/mpi

env:
- PIP_VER=9.0.1 TEST_SHELL_CMD=zsh LANG=C
- PIP_VER=9.0.1 TEST_SHELL_CMD=zsh LANG=en_US.utf-8
Expand Down Expand Up @@ -31,10 +35,10 @@ python:
# - "3.2"
# - "3.3"
# - "3.4"
- 3.5
# - 3.5
# - "3.5-dev" # 3.5 development branch
- 3.6
- 3.7-dev
- 3.7-dev # To be '3.7' ?
- "nightly"

cache:
Expand All @@ -54,14 +58,10 @@ addons:
- ibverbs-utils
- libibverbs-dev
- zsh
- libmpich-dev
- mpich
- libopenmpi-dev
- openmpi-bin
- openmpi-common

before_script:
- echo # sh ./.travis_install.sh
- export MPI=openmpi-3.1.2
- bash tests/build_mpi.sh

install:
- pip install "pip==${PIP_VER}"
Expand All @@ -71,5 +71,8 @@ script:
- autopep8 --diff -r . --global-config .pep8 | tee check_autopep8
- test ! -s check_autopep8
- flake8 $(find . -name "*.py")
- export MPI=$HOME/mpienv/openmpi-3.1.2
- export PATH=$MPI/bin:$PATH
- export LD_LIBRARY_PATH=$MPI/lib:$LD_LIBRARY_PATH
- ${TEST_SHELL_CMD} ./tests/test_main.sh
# - codeclimate-test-reporter || true # CODECLIMATE_REPO_TOKEN is defined in TravisCI's setting
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ $ git clone https://github.com/keisukefukuda/mpienv.git .mpienv
First, you need to load the `mpienv` tool into your shell environment.

```bash
$ . ~/.mpienv/init
$ . ~/.mpienv/mpienv-init
```

If you downloaded `mpienv` to a different location, just replace the path.

```bash
$ . ${YOUR_MPIENV_DIRECTORY}/init
$ . ${YOUR_MPIENV_DIRECTORY}/mpienv-init
```

OK, let's see what `mpienv` does.
Expand Down
File renamed without changes.
81 changes: 42 additions & 39 deletions bin/autodiscover.py → bin/mpienv-autodiscover.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ def list_mpiexec(dirpath):
* if the filename is 'mpiexec', then it's selected.
* If a file "the_file.replace('mpiexec', 'mpicc')" exists,
then the_file is selected.
* If a filename matches r'mpiexec.*mpi*', it is chosen.
* Otherwise, one is randomly chosen
* If a filename matches r'mpiexec.*mpi*', it is selected.
* Otherwise, one is randomly selected
"""

lst = glob.glob(os.path.join(_glob_escape(dirpath), 'bin', '*mpiexec*'))
link_rel = {}

Expand Down Expand Up @@ -122,53 +121,57 @@ def list_mpiexec(dirpath):
break
else:
res.append(cands[0])

return res


def install_mpi(path, mpiexec):
try:
name = mpienv.add(mpiexec)
prints("Added {} as {}".format(path, name))

except OSError as e:
if e.errno == errno.EEXIST:
sys.stderr.write("Tried to register '{}', "
"but the name is already taken "
"by another MPI instance. "
"Please use `mpienv add` with"
" `-n` option manually.\n".format(
name))
else:
raise
except RuntimeError as e:
prints("Error occured while "
"adding {}".format(path))
prints(e)
prints()


def investigate_path(path, flg_to_add, done={}):
for mpiexec in list_mpiexec(path):
if mpiexec in done:
continue
else:
done.add(mpiexec)

if os.path.isfile(mpiexec):
printv("checking {}".format(mpiexec))

# Exclude mpienv's own directory
name = mpienv.is_installed(path)
if name:
prints("{}\n\t Already known as "
"'{}'".format(path, name))
prints()
else:
prints("--------------------------------------")
prints("Found {}".format(mpiexec))
prints(pprint.pformat(mpienv.get_mpi_from_mpiexec(mpiexec)))
# Install the new MPI
if flg_to_add:
try:
name = mpienv.add(mpiexec)
prints("Added {} as {}".format(path, name))

except OSError as e:
if e.errno == errno.EEXIST:
sys.stderr.write("Tried to register '{}', "
"but the name is already taken "
"by another MPI instance. "
"Please use `mpienv add` with"
" `-n` option manually.\n".format(
name))
else:
raise
except RuntimeError as e:
prints("Error occured while "
"adding {}".format(path))
prints(e)
prints()
else:
if not os.path.isfile(mpiexec):
printv("No such file '{}'".format(mpiexec))
continue

printv("checking {}".format(mpiexec))

# Exclude mpienv's own directory
name = mpienv.is_installed(path)
if name:
prints("{}\n\t Already known as "
"'{}'".format(path, name))
prints()
else:
prints("--------------------------------------")
prints("Found {}".format(mpiexec))
prints(pprint.pformat(mpienv.get_mpi_from_mpiexec(mpiexec)))
# Install the new MPI
if flg_to_add:
install_mpi(path, mpiexec)

return done

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 18 additions & 15 deletions init → bin/mpienv-init
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

export MPIENV_ROOT="$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)"
cat <<'EOF'
export MPIENV_ROOT="$HOME/.mpienv"
if [ -z "${MPIENV_VERSIONS_DIR:-}" ]; then
export MPIENV_VERSIONS_DIR=$MPIENV_ROOT/versions
Expand Down Expand Up @@ -38,7 +39,7 @@ function mpienv() {
"use" )
{
eval $(env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/use.py $*)
mpienv-use.py $*)
if [ -z "${BASH_VERSION:-}" -a ! -z "${ZSH_VERSION:-}" ]; then
rehash
fi
Expand All @@ -47,83 +48,85 @@ function mpienv() {
"configure" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/configure.py "$@"
mpienv-configure.py "$@"
}
;;
"build" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/build.py "$@"
mpienv-build.py "$@"
}
;;
"install" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/install.py "$@"
mpienv-install.py "$@"
}
;;
"clean" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/clean.py "$@"
mpienv-clean.py "$@"
}
;;
"add" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/add.py $*
mpienv-add.py $*
}
;;
"rm" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/rm.py "$@"
mpienv-rm.py "$@"
}
;;
"rename" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/rename.py "$@"
mpienv-rename.py "$@"
}
;;
"list" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/list.py "$@"
mpienv-list.py "$@"
}
;;
"info" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/info.py "$@"
mpienv-info.py "$@"
}
;;
"autodiscover" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/autodiscover.py "$@"
mpienv-autodiscover.py "$@"
}
;;
"prefix" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/prefix.py "$@"
mpienv-prefix.py "$@"
}
;;
"exec" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/exec.py "$@"
mpienv-exec.py "$@"
}
;;
"help" )
{
env PYTHONPATH=$MPIENV_ROOT:${PYTHONPATH:-} \
python $root/bin/help.py "$@"
mpienv-help.py "$@"
}
;;
* )
echo "mpienv [ERROR]: Unknown command '$command'"
;;
esac
}
EOF

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion mpienv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _load_config(self):
with open(conf_json) as f:
conf = json.load(f)
else:
sys.stderr.write("Warning: Cannot find config file\n")
# sys.stderr.write("Warning: Cannot find config file\n")
conf = {}

self._conf = DefaultConf.copy()
Expand Down
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from setuptools import setup

setup(
name="mpienv",
version="0.1",
scripts=['bin/mpienv-init',
'bin/mpienv-add.py',
'bin/mpienv-autodiscover.py',
'bin/mpienv-build.py',
'bin/mpienv-configure.py',
'bin/mpienv-exec.py',
'bin/mpienv-help.py',
'bin/mpienv-info.py',
'bin/mpienv-install.py',
'bin/mpienv-list.py',
'bin/mpienv-prefix.py',
'bin/mpienv-rename.py',
'bin/mpienv-rm.py',
'bin/mpienv-use.py'],
packages=['mpienv'],
)
Loading

0 comments on commit 04ec11e

Please sign in to comment.