diff --git a/install-utilities.sh b/install-utilities.sh index 3e8ada8..3ac371d 100755 --- a/install-utilities.sh +++ b/install-utilities.sh @@ -105,6 +105,7 @@ function read_ncsdk_config() INSTALL_TOOLKIT=yes PIP_SYSTEM_INSTALL=yes USE_VIRTUALENV=no + VIRTUALENV_DIR=${INSTALL_DIR}/virtualenv-python ### set # jobs to make simultaneously, MAKE_NJOBS, defaults to 1. diff --git a/install.sh b/install.sh index a1d2e35..675cf1e 100755 --- a/install.sh +++ b/install.sh @@ -29,7 +29,7 @@ function check_supported_os() VERSION="$(lsb_release -r 2>/dev/null | awk '{ print $2 }' | sed 's/[.]//')" OS_DISTRO="${DISTRO:-INVALID}" OS_VERSION="${VERSION:-255}" - if [ "${OS_DISTRO,,}" = "ubuntu" ] && [ ${OS_VERSION} = 1604 ]; then + if [ "${OS_DISTRO,,}" = "ubuntu" ] && [[ ${OS_VERSION} = 1604 || ${OS_VERSION} = 1804 ]]; then # Require 64-bit Ubuntu OS HARDWARE_PLATFORM=$(uname -i) if [ "${HARDWARE_PLATFORM}" != "x86_64" ] ; then @@ -104,6 +104,7 @@ function print_ncsdk_config() echo "PIP_SYSTEM_INSTALL - Globally install pip packages via sudo -H" echo "VERBOSE - Flag to enable more verbose installation" echo "USE_VIRTUALENV - Flag to enable python virtualenv" + echo "VIRTUALENV_DIR - Virtual environment directory" echo "MAKE_NJOBS - Number of processes to use for parallel build (i.e. make -j MAKE_NJOBS)" echo "" echo "INSTALL_DIR=${INSTALL_DIR}" @@ -115,6 +116,7 @@ function print_ncsdk_config() echo "PIP_SYSTEM_INSTALL=${PIP_SYSTEM_INSTALL}" echo "VERBOSE=${VERBOSE}" echo "USE_VIRTUALENV=${USE_VIRTUALENV}" + echo "VIRTUALENV_DIR=${VIRTUALENV_DIR}" echo "MAKE_NJOBS=${MAKE_NJOBS}" echo "" } @@ -314,7 +316,6 @@ function setup_virtualenv() ${SUDO_PREFIX} apt-get $APT_QUIET install python-virtualenv -y echo "" - VIRTUALENV_DIR=${INSTALL_DIR}/virtualenv-python # if virtualenv dir exists, try to activate it if [ -d ${VIRTUALENV_DIR} ] ; then RC=0 @@ -329,13 +330,14 @@ function setup_virtualenv() exit 1 echo "" else - echo "virtualenv ${INSTALL_DIR}/virtualenv-python exists, and successfully activated it" + echo "virtualenv ${VIRTUALENV_DIR} exists, and successfully activated it" fi else # Create new virtualenv and activate it echo "Creating new virtualenv in ${VIRTUALENV_DIR}" ${SUDO_PREFIX} mkdir -p ${VIRTUALENV_DIR} ${SUDO_PREFIX} virtualenv --system-site-packages -p python3 ${VIRTUALENV_DIR} + ${SUDO_PREFIX} chown -R $USER:$USER ${VIRTUALENV_DIR} # disable trapping for unset variables due to activate script set +u RC=0 @@ -740,9 +742,13 @@ function install_api() # Install python API $SUDO_PREFIX cp ${FROM_DIR}/api/python/mvnc/mvncapi.py $SDK_DIR/api/python/mvnc $SUDO_PREFIX cp ${FROM_DIR}/api/python/mvnc/__init__.py $SDK_DIR/api/python/mvnc - exec_and_search_errors "$PIP_PREFIX pip3 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" - exec_and_search_errors "$PIP_PREFIX pip2 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" - echo "NCS Python API has been installed in $INSTALL_DIR, and PYTHONPATH environment variable updated" + if [ "${USE_VIRTUALENV}" == 'yes' ]; then + exec_and_search_errors "$PIP_PREFIX pip install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" + else + exec_and_search_errors "$PIP_PREFIX pip3 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" + exec_and_search_errors "$PIP_PREFIX pip2 install $PIP_QUIET --upgrade --force-reinstall $SDK_DIR/api" + fi + echo "NCS Python API has been installed in $INSTALL_DIR, and PYTHONPATH environment variable updated" } diff --git a/ncsdk.conf b/ncsdk.conf index c5b7aed..1225cd4 100644 --- a/ncsdk.conf +++ b/ncsdk.conf @@ -1,10 +1,11 @@ INSTALL_DIR=/opt/movidius -INSTALL_CAFFE=yes +INSTALL_CAFFE=no CAFFE_FLAVOR=ssd CAFFE_USE_CUDA=no -INSTALL_TENSORFLOW=yes -INSTALL_TOOLKIT=yes -PIP_SYSTEM_INSTALL=yes +INSTALL_TENSORFLOW=no +INSTALL_TOOLKIT=no +PIP_SYSTEM_INSTALL=no VERBOSE=yes USE_VIRTUALENV=no +VIRTUALENV_DIR=/opt/movidius/virtualenv-python #MAKE_NJOBS=1 diff --git a/uninstall.sh b/uninstall.sh index 0336072..b99e9e3 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -57,6 +57,30 @@ function remove_install_dir() } +function initialize_virtualenv() +{ + # if virtualenv dir exists, try to activate it + if [ -d ${VIRTUALENV_DIR} ] ; then + RC=0 + # disable trapping for unset variables due to activate script + set +u + source ${VIRTUALENV_DIR}/bin/activate || RC=$? + set -u + if [ ${RC} -ne 0 ] ; then + echo "source ${VIRTUALENV_DIR}/bin/activate gave an error=${RC}" + echo "You need to investigate: 1) Either figure out why virtualenv is not activating correctly or" + echo " 2) edit ncsdk.conf to set USE_VIRTUALENV=no to disable virtualenv. Will exit" + exit 1 + echo "" + else + echo "virtualenv ${VIRTUALENV_DIR} exists, and successfully activated it" + fi + else + echo "Supplied virtualenv dir does not exist." + fi +} + + # main - this is the main function that runs the uninstall function main() { @@ -76,6 +100,9 @@ function main() ### function is in install-utilities.sh find_previous_install + + # Optionally use python virtualenv, USE_VIRTUALENV set in ncsdk.conf + [ "${USE_VIRTUALENV}" == 'yes' ] && initialize_virtualenv ### remove prev installation. Function is in install-utilities.sh remove_previous_install