diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-09 13:45:27 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-09 13:45:27 -0400 |
commit | 6b6940e59abba27c110ab33a68e5e11c5bd5962c (patch) | |
tree | 4f12eb3655207a291a938630bc62f46151fccb60 /with_env | |
download | docker-buildsys-py-6b6940e59abba27c110ab33a68e5e11c5bd5962c.tar.gz |
Initial commit
Diffstat (limited to 'with_env')
-rwxr-xr-x | with_env | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/with_env b/with_env new file mode 100755 index 0000000..c94e8b9 --- /dev/null +++ b/with_env @@ -0,0 +1,36 @@ +#!/bin/bash +set +x +environ=base +commands=() + +while [[ $# > 0 ]] +do + key="$1" + case $key in + -n|--name) + environ="$2" + shift 2 + ;; + *) + commands+=("$1") + shift + ;; + esac +done + + +type conda &>/dev/null +if [[ $? != 0 ]]; then + venv_root=${HOME}/.venvs + venv_path=${venv_root}/${environ} + + [[ ! -d ${venv_root} ]] && mkdir -p ${venv_root} + [[ ! -d ${venv_path} ]] && python -m venv "${venv_path}" + + source "${venv_path}/bin/activate" +else + source activate ${environ} +fi + +"${commands[@]}" +exit $? |