blob: 245785c826949791c8016cb7cd0da6d1601e2914 [file] [log] [blame]
Brad Bishop6a62e0e2019-10-21 08:11:42 -04001From 07fce2101d83b5334de78e661ba0361c2874ebdf Mon Sep 17 00:00:00 2001
Brad Bishop34ae6002019-04-08 15:21:03 -04002From: Alistair Francis <alistair.francis@wdc.com>
3Date: Mon, 18 Mar 2019 16:30:45 -0700
Brad Bishop2d39a062019-10-28 08:33:36 -04004Subject: [PATCH 1/7] Remove python venv
Brad Bishop34ae6002019-04-08 15:21:03 -04005
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---
Brad Bishop6a62e0e2019-10-21 08:11:42 -040012 dev_setup.sh | 39 ---------------------------------------
Brad Bishop34ae6002019-04-08 15:21:03 -040013 start-mycroft.sh | 13 -------------
14 venv-activate.sh | 44 +-------------------------------------------
Brad Bishop6a62e0e2019-10-21 08:11:42 -040015 3 files changed, 1 insertion(+), 95 deletions(-)
Brad Bishop34ae6002019-04-08 15:21:03 -040016
17diff --git a/dev_setup.sh b/dev_setup.sh
Brad Bishop6a62e0e2019-10-21 08:11:42 -040018index cf81ed25f0f..99a44bfd8a7 100755
Brad Bishop34ae6002019-04-08 15:21:03 -040019--- a/dev_setup.sh
20+++ b/dev_setup.sh
Brad Bishop6a62e0e2019-10-21 08:11:42 -040021@@ -338,18 +338,6 @@ ${YELLOW}Make sure to manually install:$BLUE git python3 python-setuptools pytho
Brad Bishop34ae6002019-04-08 15:21:03 -040022 fi
23 }
24
25-VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${TOP}/.venv"}
26-
27-function install_venv() {
Brad Bishop6a62e0e2019-10-21 08:11:42 -040028- $opt_python -m venv "${VIRTUALENV_ROOT}/" --without-pip
Brad Bishop34ae6002019-04-08 15:21:03 -040029- # 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
Brad Bishop6a62e0e2019-10-21 08:11:42 -040034- [[ -x ${VIRTUALENV_ROOT}/bin/pip ]]
Brad Bishop34ae6002019-04-08 15:21:03 -040035-}
36-
37 install_deps
38
39 # Configure to use the standard commit template for
Brad Bishop6a62e0e2019-10-21 08:11:42 -040040@@ -383,17 +371,6 @@ else
Brad Bishop34ae6002019-04-08 15:21:03 -040041 fi
42 fi
43
Brad Bishop6a62e0e2019-10-21 08:11:42 -040044-if [[ ! -x ${VIRTUALENV_ROOT}/bin/activate ]] ; then
Brad Bishop34ae6002019-04-08 15:21:03 -040045- if ! install_venv ; then
Brad Bishop6a62e0e2019-10-21 08:11:42 -040046- echo 'Failed to set up virtualenv for mycroft, exiting setup.'
Brad Bishop34ae6002019-04-08 15:21:03 -040047- exit 1
48- fi
49-fi
50-
Brad Bishop6a62e0e2019-10-21 08:11:42 -040051-# Start the virtual environment
Brad Bishop34ae6002019-04-08 15:21:03 -040052-source "${VIRTUALENV_ROOT}/bin/activate"
Brad Bishop6a62e0e2019-10-21 08:11:42 -040053-cd "$TOP"
54-
Brad Bishop34ae6002019-04-08 15:21:03 -040055 # Install pep8 pre-commit hook
Brad Bishop6a62e0e2019-10-21 08:11:42 -040056 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
Brad Bishop34ae6002019-04-08 15:21:03 -040059
Brad Bishop6a62e0e2019-10-21 08:11:42 -040060 PYTHON=$(python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))")
Brad Bishop34ae6002019-04-08 15:21:03 -040061
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"
Brad Bishop6a62e0e2019-10-21 08:11:42 -040066-if [[ ! -f $VENV_PATH_FILE ]] ; then
67- echo 'import sys; sys.__plen = len(sys.path)' > "$VENV_PATH_FILE" || return 1
Brad Bishop34ae6002019-04-08 15:21:03 -040068- 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
Brad Bishop6a62e0e2019-10-21 08:11:42 -040072- echo 'Adding mycroft-core to virtualenv path'
Brad Bishop34ae6002019-04-08 15:21:03 -040073- sed -i.tmp '1 a\
74-'"$TOP"'
Brad Bishop6a62e0e2019-10-21 08:11:42 -040075-' "$VENV_PATH_FILE"
Brad Bishop34ae6002019-04-08 15:21:03 -040076-fi
77-
78 # install required python modules
79 if ! pip install -r requirements.txt ; then
Brad Bishop6a62e0e2019-10-21 08:11:42 -040080 echo 'Warning: Failed to install all requirements. Continue? y/N'
Brad Bishop34ae6002019-04-08 15:21:03 -040081diff --git a/start-mycroft.sh b/start-mycroft.sh
Brad Bishop6a62e0e2019-10-21 08:11:42 -040082index 0f88430982e..3aed2f189d4 100755
Brad Bishop34ae6002019-04-08 15:21:03 -040083--- 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
Brad Bishop6a62e0e2019-10-21 08:11:42 -0400135 make ${_params}
Brad Bishop34ae6002019-04-08 15:21:03 -0400136 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--
Brad Bishop6a62e0e2019-10-21 08:11:42 -04001932.23.0
Brad Bishop34ae6002019-04-08 15:21:03 -0400194