1.2.4. Conda installer scriptΒΆ

Here is an example of bash script with options that can help you install conda, vacumm and its dependencies in a single command. You can either execute this script or create yours, inspired from this one.

You can download the script here.

Usage, with defaults depending on platform:

Usage:

install-vacumm-conda-full.sh [-h|--help] [{-p|--prefix} PREFIX] [{-c|--condainstaller} CONDA_INSTALLER]

 PREFIX: installation prefix (default: $HOME/miniconda2)
 CONDA_INSTALLER: conda installer full path (default: $HOME/Miniconda2-latest-Linux-x86_64.sh)

Content:

#!/bin/bash

usage() {
    echo "$(basename $0) [-h|--help] [{-p|--prefix} PREFIX] [{-c|--condainstaller} CONDA_INSTALLER]"
}

KERNEL=$(uname -s)
HARDWARE=$(uname -i)
DEFAULT_PREFIX=$HOME/miniconda2
DEFAULT_CONDA_INSTALLER=$HOME/src/Miniconda2-latest-$KERNEL-$HARDWARE.sh

_help() {
    echo "Usage:"
    echo
    usage
    echo
    echo " PREFIX: installation prefix (default: $DEFAULT_PREFIX)"
    echo " CONDA_INSTALLER: conda installer full path (default: $DEFAULT_CONDA_INSTALLER)"
}

while [[ $# > 0 ]]
do
    key="$1"

    case $key in
        -h|--help)
        _help
        exit 0
        ;;
        -p|--prefix)
        PREFIX="$2"
        shift
        ;;
        -c|--condainstaller)
        CONDA_INSTALLER="$2"
        shift
        ;;
        *)
        echo "Wrong usage"
        usage
        exit 1
        ;;
    esac
    shift
done

# Default values
test -z $PREFIX && PREFIX=$DEFAULT_PREFIX
test -z $CONDA_INSTALLER && CONDA_INSTALLER=$DEFAULT_CONDA_INSTALLER

# Show config
echo "Will install conda with vacumm and dependencies in $PREFIX with installer $CONDA_INSTALLER"
echo "Ok?"
read

# Erase
if test -d "$PREFIX" ; then
    echo "Remove existing installation ?"
    echo "  $PREFIX"
    read
    rm -rf $PREFIX
fi

# Installer
if ! test -f $CONDA_INSTALLER ; then
    echo "Downloading conda installer..."
    mkdir -p $(dirname $CONDA_INSTALLER)
    wget -O $CONDA_INSTALLER https://repo.continuum.io/miniconda/$(basename $CONDA_INSTALLER) || ( echo "Error downloading conda installer" ; exit 1)
fi
chmod +x $CONDA_INSTALLER

# Install conda
$CONDA_INSTALLER -p $PREFIX -b || ( echo "Installation of conda failed" && exit 1 )
export PATH=$PREFIX/bin:$PATH

# Install vacumm and dependencies
#conda install -y -c cdat cdat || ( echo "Installation of cdat failed" && exit 1 )
#conda install -y -c conda-forge configobj PIL paramiko xlutils seawater pytz cmocean || ( echo "Installation of other dependencies failed" && exit 1 )
conda install -y vacumm || ( echo "Installation of vacumm failed" && exit 1 )

echo
echo "To test it:"
echo "  $PREFIX/bin/python -c 'import vcmq'"