Deal with case of nor pre-existing .pth file
Add support for a perfectly clean virtualenv that doesn't have a
_virtualenv_path_extensions.pth file already.
@@ -81,14 +81,19 @@ pip install --upgrade virtualenv
# Add mycroft-core to the virtualenv path
# (This is equivalent to typing 'add2virtualenv $TOP', except
# you can't invoke that shell function from inside a script)
-if ! grep -q "mycroft-core" "${VIRTUALENV_ROOT}/lib/python2.7/site-packages/_virtualenv_path_extensions.pth"; then
+VENV_PATH_FILE="${VIRTUALENV_ROOT}/lib/python2.7/site-packages/_virtualenv_path_extensions.pth"
+if [ ! -f "$VENV_PATH_FILE" ] ; then
+ echo "import sys; sys.__plen = len(sys.path)" > "$VENV_PATH_FILE" || return 1
+ echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$VENV_PATH_FILE" || return 1
+fi
+
+if ! grep -q "mycroft-core" $VENV_PATH_FILE; then
echo "Adding mycroft-core to virtualenv path"
sed -i.tmp '1 a\
'"$TOP"'
-' "${VIRTUALENV_ROOT}/lib/python2.7/site-packages/_virtualenv_path_extensions.pth"
+' "${VENV_PATH_FILE}"
fi
-
# install requirements (except pocketsphinx)
# removing the pip2 explicit usage here for consistency with the above use.
pip install -r requirements.txt
