
# Symlink this file so it is in the top-level Greenstone3 directory area

source ./gs3-setup.sh

function check_pip_installed()
{
    if [ ! -d "$GEXT_MARS_INSTALLED/virtualenv-python3/lib/python3.7/site-packages/$1" ] \
	&& [ ! -f "$GEXT_MARS_INSTALLED/virtualenv-python3/lib/python3.7/site-packages/$1.py" ] ; then
	echo "!!!!" >&2
	echo "! Failed to find directory or file: " >&2
	echo "!   $GEXT_MARS_INSTALLED/virtualenv-python3/lib/python3.7/site-packages/$1(.py)" >&2
	echo "!!!!" >&2
	echo "! You need to: " >&2
	if [ "x$VIRTUAL_ENV" = "x" ] ; then
	    echo "!   source $GEXT_MARS/$GSDLOS/virtualenv-python3/bin/activate" >&2
	    echo "! Then: " >&2
	fi
	echo "!   pip install $1" >&2
	echo "!!!!" >&2
	
	return 1
    fi
}

function check_pip_installed_all()
{
    for pkg in six sklearn matplotlib ; do
	check_pip_installed $pkg
	if [ $? != 0 ] ; then
	    return 1
	fi
    done
}


check_pip_installed_all

if [ $? != 0 ] ; then
    return 1
fi

if [ "x$VIRTUAL_ENV" = "x" ] ; then

    echo ""
    echo "****"
    echo "* Activating Python v3 Virtual Env "
    echo "****"
    echo ""

    source $GEXT_MARS_INSTALLED/virtualenv-python3/bin/activate
fi

