setup_anaconda.sh 966 Bytes
Newer Older
Willi Rath's avatar
Willi Rath committed
1 2 3
#!/bin/bash

# how to use?
4 5 6 7 8 9 10 11 12 13 14 15 16
if [ $# -lt 2 ]; then
    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 ""
    exit
fi

# create time stamp for this installation
time_stamp=`date +%s%N`
Willi Rath's avatar
Willi Rath committed
17 18 19 20 21 22 23

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

# download miniconda
installer=/tmp/${time_stamp}_miniconda3.sh
24 25
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    -O ${installer}
Willi Rath's avatar
Willi Rath committed
26 27 28 29 30 31

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

# activate root environment of installation
Willi Rath's avatar
Willi Rath committed
32
source ${target_dir}/bin/activate root || exit 1
Willi Rath's avatar
Willi Rath committed
33

34 35 36 37 38 39
# install all of the specified envs
echo "installing env files:"
echo "${@:2}"
for f in "${@:2}"; do
    conda env create -q -f $f || exit 1
done