blob: c03bccd3da88e3355b593e95b03dd3ba2092a7b4 [file] [log] [blame]
Brad Bishop34ae6002019-04-08 15:21:03 -04001From 6272f36080bd440a5825b526f4c06223c5bb9fbb 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/5] 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 | 36 ------------------------------------
13 start-mycroft.sh | 13 -------------
14 venv-activate.sh | 44 +-------------------------------------------
15 3 files changed, 1 insertion(+), 92 deletions(-)
16
17diff --git a/dev_setup.sh b/dev_setup.sh
18index e0b07bf25cf..aed54b2167a 100755
19--- a/dev_setup.sh
20+++ b/dev_setup.sh
21@@ -310,18 +310,6 @@ function install_deps() {
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@@ -355,15 +343,7 @@ 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@@ -380,22 +360,6 @@ fi
57
58 PYTHON=$( python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))" )
59
60-# Add mycroft-core to the virtualenv path
61-# (This is equivalent to typing 'add2virtualenv $TOP', except
62-# you can't invoke that shell function from inside a script)
63-VENV_PATH_FILE="${VIRTUALENV_ROOT}/lib/$PYTHON/site-packages/_virtualenv_path_extensions.pth"
64-if [ ! -f "$VENV_PATH_FILE" ] ; then
65- echo "import sys; sys.__plen = len(sys.path)" > "$VENV_PATH_FILE" || return 1
66- 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
67-fi
68-
69-if ! grep -q "$TOP" $VENV_PATH_FILE ; then
70- echo "Adding mycroft-core to virtualenv path"
71- sed -i.tmp '1 a\
72-'"$TOP"'
73-' "${VENV_PATH_FILE}"
74-fi
75-
76 # install required python modules
77 if ! pip install -r requirements.txt ; then
78 echo "Warning: Failed to install all requirements. Continue? y/N"
79diff --git a/start-mycroft.sh b/start-mycroft.sh
80index b9514a61ba5..64e0216a62f 100755
81--- a/start-mycroft.sh
82+++ b/start-mycroft.sh
83@@ -20,7 +20,6 @@ script=${0}
84 script=${script##*/}
85 cd -P "$( dirname "$SOURCE" )"
86 DIR="$( pwd )"
87-VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${DIR}/.venv"}
88
89 function help() {
90 echo "${script}: Mycroft command/service launcher"
91@@ -76,19 +75,11 @@ function name-to-script-path() {
92 esac
93 }
94
95-function source-venv() {
96- # Enter Python virtual environment, unless under Docker
97- if [ ! -f "/.dockerenv" ] ; then
98- source ${VIRTUALENV_ROOT}/bin/activate
99- fi
100-}
101-
102 first_time=true
103 function init-once() {
104 if ($first_time) ; then
105 echo "Initializing..."
106 "${DIR}/scripts/prepare-msm.sh"
107- source-venv
108 first_time=false
109 fi
110 }
111@@ -225,15 +216,12 @@ case ${_opt} in
112 # launch-background ${_opt}
113 # ;;
114 "unittest")
115- source-venv
116 pytest test/unittests/ --cov=mycroft "$@"
117 ;;
118 "singleunittest")
119- source-venv
120 pytest "$@"
121 ;;
122 "skillstest")
123- source-venv
124 pytest test/integrationtests/skills/discover_tests.py "$@"
125 ;;
126 "audiotest")
127@@ -243,7 +231,6 @@ case ${_opt} in
128 launch-process ${_opt}
129 ;;
130 "sdkdoc")
131- source-venv
132 cd doc
133 make ${opt}
134 cd ..
135diff --git a/venv-activate.sh b/venv-activate.sh
136index d1e7bcb44e7..10b46d4de3b 100644
137--- a/venv-activate.sh
138+++ b/venv-activate.sh
139@@ -22,49 +22,7 @@
140
141 # wrap in function to allow local variables, since this file will be source'd
142 function main() {
143- local quiet=0
144-
145- for arg in "$@"
146- do
147- case $arg in
148- "-q"|"--quiet" )
149- quiet=1
150- ;;
151-
152- "-h"|"--help" )
153- echo "venv-activate.sh: Enter the Mycroft virtual environment"
154- echo "Usage:"
155- echo " source venv-activate.sh"
156- echo "or"
157- echo " . venv-activate.sh"
158- echo ""
159- echo "Options:"
160- echo " -q | --quiet Don't show instructions."
161- echo " -h | --help Show help."
162- return 0
163- ;;
164-
165- *)
166- echo "ERROR: Unrecognized option: $@"
167- return 1
168- ;;
169- esac
170- done
171-
172- if [ "$0" == "$BASH_SOURCE" ] ; then
173- # Prevent running in script then exiting immediately
174- echo "ERROR: Invoke with 'source venv-activate.sh' or '. venv-activate.sh'"
175- else
176- local SRC_DIR="$( builtin cd "$( dirname "${BASH_SOURCE}" )" ; pwd -P )"
177- source ${SRC_DIR}/.venv/bin/activate
178-
179- # Provide an easier to find "mycroft-" prefixed command.
180- unalias mycroft-venv-activate 2>/dev/null
181- alias mycroft-venv-deactivate="deactivate && unalias mycroft-venv-deactivate 2>/dev/null && alias mycroft-venv-activate=\"source '${SRC_DIR}/venv-activate.sh'\""
182- if [ $quiet -eq 0 ] ; then
183- echo "Entering Mycroft virtual environment. Run 'mycroft-venv-deactivate' to exit"
184- fi
185- fi
186+ echo "Not entering Python VENV"
187 }
188
189 main $@
190--
1912.21.0
192