1From 07fce2101d83b5334de78e661ba0361c2874ebdf Mon Sep 17 00:00:00 2001 2From: Alistair Francis <alistair.francis@wdc.com> 3Date: Mon, 18 Mar 2019 16:30:45 -0700 4Subject: [PATCH 1/7] Remove python venv 5 6Remove the python venv requirements and instead just use the native 7python and pip pacakges. 8 9Signed-off-by: Alistair Francis <alistair.francis@wdc.com> 10Upstream-Status: Inappropriate [embedded specific] 11--- 12 dev_setup.sh | 39 --------------------------------------- 13 start-mycroft.sh | 13 ------------- 14 venv-activate.sh | 44 +------------------------------------------- 15 3 files changed, 1 insertion(+), 95 deletions(-) 16 17diff --git a/dev_setup.sh b/dev_setup.sh 18index cf81ed25f0f..99a44bfd8a7 100755 19--- a/dev_setup.sh 20+++ b/dev_setup.sh 21@@ -338,18 +338,6 @@ ${YELLOW}Make sure to manually install:$BLUE git python3 python-setuptools pytho 22 fi 23 } 24 25-VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${TOP}/.venv"} 26- 27-function install_venv() { 28- $opt_python -m venv "${VIRTUALENV_ROOT}/" --without-pip 29- # Force version of pip for reproducability, but there is nothing special 30- # about this version. Update whenever a new version is released and 31- # verified functional. 32- curl https://bootstrap.pypa.io/3.3/get-pip.py | "${VIRTUALENV_ROOT}/bin/python" - 'pip==18.0.0' 33- # Function status depending on if pip exists 34- [[ -x ${VIRTUALENV_ROOT}/bin/pip ]] 35-} 36- 37 install_deps 38 39 # Configure to use the standard commit template for 40@@ -383,17 +371,6 @@ else 41 fi 42 fi 43 44-if [[ ! -x ${VIRTUALENV_ROOT}/bin/activate ]] ; then 45- if ! install_venv ; then 46- echo 'Failed to set up virtualenv for mycroft, exiting setup.' 47- exit 1 48- fi 49-fi 50- 51-# Start the virtual environment 52-source "${VIRTUALENV_ROOT}/bin/activate" 53-cd "$TOP" 54- 55 # Install pep8 pre-commit hook 56 HOOK_FILE='./.git/hooks/pre-commit' 57 if [[ -n $INSTALL_PRECOMMIT_HOOK ]] || grep -q 'MYCROFT DEV SETUP' $HOOK_FILE; then 58@@ -408,22 +385,6 @@ fi 59 60 PYTHON=$(python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))") 61 62-# Add mycroft-core to the virtualenv path 63-# (This is equivalent to typing 'add2virtualenv $TOP', except 64-# you can't invoke that shell function from inside a script) 65-VENV_PATH_FILE="${VIRTUALENV_ROOT}/lib/$PYTHON/site-packages/_virtualenv_path_extensions.pth" 66-if [[ ! -f $VENV_PATH_FILE ]] ; then 67- echo 'import sys; sys.__plen = len(sys.path)' > "$VENV_PATH_FILE" || return 1 68- 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 69-fi 70- 71-if ! grep -q "$TOP" $VENV_PATH_FILE ; then 72- echo 'Adding mycroft-core to virtualenv path' 73- sed -i.tmp '1 a\ 74-'"$TOP"' 75-' "$VENV_PATH_FILE" 76-fi 77- 78 # install required python modules 79 if ! pip install -r requirements.txt ; then 80 echo 'Warning: Failed to install all requirements. Continue? y/N' 81diff --git a/start-mycroft.sh b/start-mycroft.sh 82index 0f88430982e..3aed2f189d4 100755 83--- a/start-mycroft.sh 84+++ b/start-mycroft.sh 85@@ -20,7 +20,6 @@ script=${0} 86 script=${script##*/} 87 cd -P "$( dirname "$SOURCE" )" 88 DIR="$( pwd )" 89-VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${DIR}/.venv"} 90 91 function help() { 92 echo "${script}: Mycroft command/service launcher" 93@@ -76,19 +75,11 @@ function name-to-script-path() { 94 esac 95 } 96 97-function source-venv() { 98- # Enter Python virtual environment, unless under Docker 99- if [ ! -f "/.dockerenv" ] ; then 100- source ${VIRTUALENV_ROOT}/bin/activate 101- fi 102-} 103- 104 first_time=true 105 function init-once() { 106 if ($first_time) ; then 107 echo "Initializing..." 108 "${DIR}/scripts/prepare-msm.sh" 109- source-venv 110 first_time=false 111 fi 112 } 113@@ -225,15 +216,12 @@ case ${_opt} in 114 # launch-background ${_opt} 115 # ;; 116 "unittest") 117- source-venv 118 pytest test/unittests/ --cov=mycroft "$@" 119 ;; 120 "singleunittest") 121- source-venv 122 pytest "$@" 123 ;; 124 "skillstest") 125- source-venv 126 pytest test/integrationtests/skills/discover_tests.py "$@" 127 ;; 128 "audiotest") 129@@ -243,7 +231,6 @@ case ${_opt} in 130 launch-process ${_opt} 131 ;; 132 "sdkdoc") 133- source-venv 134 cd doc 135 make ${_params} 136 cd .. 137diff --git a/venv-activate.sh b/venv-activate.sh 138index d1e7bcb44e7..10b46d4de3b 100644 139--- a/venv-activate.sh 140+++ b/venv-activate.sh 141@@ -22,49 +22,7 @@ 142 143 # wrap in function to allow local variables, since this file will be source'd 144 function main() { 145- local quiet=0 146- 147- for arg in "$@" 148- do 149- case $arg in 150- "-q"|"--quiet" ) 151- quiet=1 152- ;; 153- 154- "-h"|"--help" ) 155- echo "venv-activate.sh: Enter the Mycroft virtual environment" 156- echo "Usage:" 157- echo " source venv-activate.sh" 158- echo "or" 159- echo " . venv-activate.sh" 160- echo "" 161- echo "Options:" 162- echo " -q | --quiet Don't show instructions." 163- echo " -h | --help Show help." 164- return 0 165- ;; 166- 167- *) 168- echo "ERROR: Unrecognized option: $@" 169- return 1 170- ;; 171- esac 172- done 173- 174- if [ "$0" == "$BASH_SOURCE" ] ; then 175- # Prevent running in script then exiting immediately 176- echo "ERROR: Invoke with 'source venv-activate.sh' or '. venv-activate.sh'" 177- else 178- local SRC_DIR="$( builtin cd "$( dirname "${BASH_SOURCE}" )" ; pwd -P )" 179- source ${SRC_DIR}/.venv/bin/activate 180- 181- # Provide an easier to find "mycroft-" prefixed command. 182- unalias mycroft-venv-activate 2>/dev/null 183- alias mycroft-venv-deactivate="deactivate && unalias mycroft-venv-deactivate 2>/dev/null && alias mycroft-venv-activate=\"source '${SRC_DIR}/venv-activate.sh'\"" 184- if [ $quiet -eq 0 ] ; then 185- echo "Entering Mycroft virtual environment. Run 'mycroft-venv-deactivate' to exit" 186- fi 187- fi 188+ echo "Not entering Python VENV" 189 } 190 191 main $@ 192-- 1932.23.0 194 195