2016-05-20 14:16:01 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-05-24 05:47:00 +00:00
|
|
|
######################################################
|
|
|
|
# dev_setup.sh
|
|
|
|
# @author sean.fitzgerald (aka clusterfudge)
|
|
|
|
#
|
|
|
|
# The purpose of this script is to create a self-
|
|
|
|
# contained development environment using
|
|
|
|
# virtualenv for python dependency sandboxing.
|
|
|
|
# This script will create a virtualenv (using the
|
|
|
|
# conventions set by virtualenv-wrapper for
|
|
|
|
# location and naming) and install the requirements
|
|
|
|
# laid out in requirements.txt, pocketsphinx, and
|
|
|
|
# pygtk into the virtualenv. Mimic will be
|
|
|
|
# installed and built from source inside the local
|
|
|
|
# checkout.
|
|
|
|
#
|
|
|
|
# The goal of this script is to create a development
|
|
|
|
# environment in user space that is fully functional.
|
|
|
|
# It is expected (and even encouraged) for a developer
|
|
|
|
# to work on multiple projects concurrently, and a
|
|
|
|
# good OSS citizen respects that and does not pollute
|
|
|
|
# a developers workspace with it's own dependencies
|
|
|
|
# (as much as possible).
|
|
|
|
# </endRant>
|
|
|
|
######################################################
|
|
|
|
|
2016-05-20 14:16:01 +00:00
|
|
|
# exit on any error
|
|
|
|
set -Ee
|
|
|
|
|
2016-05-24 05:47:00 +00:00
|
|
|
if [ $(id -u) -eq 0 ]; then
|
|
|
|
echo "This script should not be run as root or with sudo."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-08-02 17:22:40 +00:00
|
|
|
# Configure to use the standard commit template for
|
|
|
|
# this repo only.
|
|
|
|
git config commit.template .gitmessage
|
|
|
|
|
2016-05-20 14:16:01 +00:00
|
|
|
TOP=$(cd $(dirname $0) && pwd -L)
|
2017-01-28 05:41:29 +00:00
|
|
|
|
|
|
|
if [ -z "$WORKON_HOME" ]; then
|
|
|
|
VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${HOME}/.virtualenvs/mycroft"}
|
|
|
|
else
|
|
|
|
VIRTUALENV_ROOT="$WORKON_HOME/mycroft"
|
|
|
|
fi
|
2016-05-20 14:16:01 +00:00
|
|
|
|
2017-07-05 19:54:05 +00:00
|
|
|
# skip mimic build?
|
|
|
|
if [[ "$1" == '-sm' ]] ; then
|
|
|
|
build_mimic='n'
|
|
|
|
fi
|
|
|
|
|
2017-07-05 20:00:16 +00:00
|
|
|
if [[ "$1" != '-sm' ]] && hash mimic ; then
|
2017-07-05 19:42:19 +00:00
|
|
|
if mimic -lv | grep -q Voice ; then
|
|
|
|
echo "Existing mimic installation. press y to build mimic again, any other key to skip."
|
|
|
|
read -n1 build_mimic
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-07-05 19:54:05 +00:00
|
|
|
|
2016-05-20 14:16:01 +00:00
|
|
|
# create virtualenv, consistent with virtualenv-wrapper conventions
|
2017-06-13 19:50:44 +00:00
|
|
|
if [ ! -d "${VIRTUALENV_ROOT}" ]; then
|
|
|
|
mkdir -p $(dirname "${VIRTUALENV_ROOT}")
|
|
|
|
virtualenv -p python2.7 "${VIRTUALENV_ROOT}"
|
2016-05-20 14:16:01 +00:00
|
|
|
fi
|
2017-06-13 19:50:44 +00:00
|
|
|
source "${VIRTUALENV_ROOT}/bin/activate"
|
|
|
|
cd "${TOP}"
|
2016-05-20 14:16:01 +00:00
|
|
|
easy_install pip==7.1.2 # force version of pip
|
2016-12-28 18:51:13 +00:00
|
|
|
pip install --upgrade virtualenv
|
2016-05-20 14:16:01 +00:00
|
|
|
|
|
|
|
# install requirements (except pocketsphinx)
|
2017-07-05 19:42:19 +00:00
|
|
|
# removing the pip2 explicit usage here for consistency with the above use.
|
|
|
|
pip install -r requirements.txt
|
2016-05-20 14:16:01 +00:00
|
|
|
|
2017-06-13 19:50:44 +00:00
|
|
|
if [[ $(free|awk '/^Mem:/{print $2}') -lt 1572864 ]] ; then
|
|
|
|
CORES=1
|
|
|
|
else
|
|
|
|
CORES=$(nproc)
|
|
|
|
fi
|
|
|
|
echo "Building with $CORES cores."
|
2016-06-20 18:34:36 +00:00
|
|
|
|
2016-07-29 19:50:38 +00:00
|
|
|
#build and install pocketsphinx
|
2016-07-29 19:58:07 +00:00
|
|
|
#cd ${TOP}
|
|
|
|
#${TOP}/scripts/install-pocketsphinx.sh -q
|
|
|
|
#build and install mimic
|
2017-06-13 19:50:44 +00:00
|
|
|
cd "${TOP}"
|
2017-07-05 19:42:19 +00:00
|
|
|
|
2017-07-06 19:31:38 +00:00
|
|
|
build_mimic="${build_mimic:-y}"
|
2017-07-05 19:42:19 +00:00
|
|
|
if [[ "$build_mimic" == 'y' ]] ; then
|
|
|
|
echo "WARNING: The following can take a long time to run!"
|
|
|
|
"${TOP}/scripts/install-mimic.sh"
|
|
|
|
else
|
|
|
|
echo "Skipping mimic build."
|
|
|
|
fi
|
2016-06-23 15:29:11 +00:00
|
|
|
|
2016-05-20 14:16:01 +00:00
|
|
|
# install pygtk for desktop_launcher skill
|
2017-06-13 19:50:44 +00:00
|
|
|
"${TOP}/scripts/install-pygtk.sh"
|