update_anaconda.sh 741 Bytes
Newer Older
1 2 3
#!/bin/bash

# how to use?
4 5 6 7 8 9 10 11 12 13
if [ $# -eq 0 ]; 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
14 15 16 17 18 19 20 21

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

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

22 23 24 25 26
# update given envs
echo "Updating env files:"
echo "${@:2}"
for f in "${@:2}"; do
    name=`cat $f | grep '^name:' | cut -d: -f2- | tr -d "[:blank:]"`
Willi Rath's avatar
Willi Rath committed
27
    grep -q 'pip:' $f && conda env remove -n ${name} -y -q
28 29
    conda env update -q -f $f || exit 1
done