Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated install scripts to allow user defined virtualenv directory #37

Open
wants to merge 3 commits into
base: ncsdk2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions install-utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 12 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -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 ""
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
}


Expand Down
9 changes: 5 additions & 4 deletions ncsdk.conf
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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
Expand Down