setup_anaconda_MacOSX.sh 1.15 KB
Newer Older
Willi Rath's avatar
Willi Rath committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#!/bin/bash

# how to use?
echo "Usage:" $0 "<target dir> [env1] [env2] ..."
echo ""
echo "<target dir> : full path to miniconda installation."
echo "               Should include time stamp or similar."
echo ""
echo "[env*]       : env files (incl. path)"
echo ""
[ $# -eq 0 ] && exit

# get target directory
target_dir=$1
echo "... installing in " ${target_dir}

# download miniconda
time_stamp=`date +%s%N`
installer=/tmp/${time_stamp}_miniconda3.sh
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ${installer}

# install miniconda and clean up
bash ${installer} -b -p ${target_dir}
rm -f ${installer}

# activate root environment of installation
source ${target_dir}/bin/activate root || exit 1

# if no envs were specified, install all given in env_files/
if [ $# -eq 1 ]; then
    echo "Installing all envs from env_files/"
    for f in env_files/*.yml; do
        conda env create -q -f $f || exit 1
    done
fi

# ifenvs were specified, install all of them
if [ $# -gt 1 ]; then
    # only install given envs
    echo "installing env files:"
    echo "${@:2}"
    for f in "${@:2}"; do
        conda env create -q -f $f || exit 1
    done
fi