aboutsummaryrefslogtreecommitdiffstats
path: root/meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch
blob: c03bccd3da88e3355b593e95b03dd3ba2092a7b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
From 6272f36080bd440a5825b526f4c06223c5bb9fbb Mon Sep 17 00:00:00 2001
From: Alistair Francis <alistair.francis@wdc.com>
Date: Mon, 18 Mar 2019 16:30:45 -0700
Subject: [PATCH 1/5] Remove python venv

Remove the python venv requirements and instead just use the native
python and pip pacakges.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Upstream-Status: Inappropriate [embedded specific]
---
 dev_setup.sh     | 36 ------------------------------------
 start-mycroft.sh | 13 -------------
 venv-activate.sh | 44 +-------------------------------------------
 3 files changed, 1 insertion(+), 92 deletions(-)

diff --git a/dev_setup.sh b/dev_setup.sh
index e0b07bf25cf..aed54b2167a 100755
--- a/dev_setup.sh
+++ b/dev_setup.sh
@@ -310,18 +310,6 @@ function install_deps() {
     fi
 }
 
-VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${TOP}/.venv"}
-
-function install_venv() {
-    ${opt_python} -m venv "${VIRTUALENV_ROOT}/" --without-pip
-    # Force version of pip for reproducability, but there is nothing special
-    # about this version.  Update whenever a new version is released and
-    # verified functional.
-    curl https://bootstrap.pypa.io/3.3/get-pip.py | "${VIRTUALENV_ROOT}/bin/python" - 'pip==18.0.0'
-    # Function status depending on if pip exists
-    [ -x "${VIRTUALENV_ROOT}/bin/pip" ]
-}
-
 install_deps
 
 # Configure to use the standard commit template for
@@ -355,15 +343,7 @@ else
     fi
 fi
 
-if [ ! -x "${VIRTUALENV_ROOT}/bin/activate" ] ; then
-    if ! install_venv ; then
-        echo "Failed to set up virtualenv for mycroft, exiting setup."
-        exit 1
-    fi
-fi
-
 # Start the virtual environment
-source "${VIRTUALENV_ROOT}/bin/activate"
 cd "${TOP}"
 
 # Install pep8 pre-commit hook
@@ -380,22 +360,6 @@ fi
 
 PYTHON=$( python -c "import sys;print('python{}.{}'.format(sys.version_info[0], sys.version_info[1]))" )
 
-# 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)
-VENV_PATH_FILE="${VIRTUALENV_ROOT}/lib/$PYTHON/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 "$TOP" $VENV_PATH_FILE ; then
-    echo "Adding mycroft-core to virtualenv path"
-    sed -i.tmp '1 a\
-'"$TOP"'
-' "${VENV_PATH_FILE}"
-fi
-
 # install required python modules
 if ! pip install -r requirements.txt ; then
     echo "Warning: Failed to install all requirements. Continue? y/N"
diff --git a/start-mycroft.sh b/start-mycroft.sh
index b9514a61ba5..64e0216a62f 100755
--- a/start-mycroft.sh
+++ b/start-mycroft.sh
@@ -20,7 +20,6 @@ script=${0}
 script=${script##*/}
 cd -P "$( dirname "$SOURCE" )"
 DIR="$( pwd )"
-VIRTUALENV_ROOT=${VIRTUALENV_ROOT:-"${DIR}/.venv"}
 
 function help() {
     echo "${script}:  Mycroft command/service launcher"
@@ -76,19 +75,11 @@ function name-to-script-path() {
     esac
 }
 
-function source-venv() {
-    # Enter Python virtual environment, unless under Docker
-    if [ ! -f "/.dockerenv" ] ; then
-        source ${VIRTUALENV_ROOT}/bin/activate
-    fi
-}
-
 first_time=true
 function init-once() {
     if ($first_time) ; then
         echo "Initializing..."
         "${DIR}/scripts/prepare-msm.sh"
-        source-venv
         first_time=false
     fi
 }
@@ -225,15 +216,12 @@ case ${_opt} in
     #    launch-background ${_opt}
     #    ;;
     "unittest")
-        source-venv
         pytest test/unittests/ --cov=mycroft "$@"
         ;;
     "singleunittest")
-        source-venv
         pytest "$@"
         ;;
     "skillstest")
-        source-venv
         pytest test/integrationtests/skills/discover_tests.py "$@"
         ;;
     "audiotest")
@@ -243,7 +231,6 @@ case ${_opt} in
         launch-process ${_opt}
         ;;
     "sdkdoc")
-        source-venv
         cd doc
         make ${opt}
         cd ..
diff --git a/venv-activate.sh b/venv-activate.sh
index d1e7bcb44e7..10b46d4de3b 100644
--- a/venv-activate.sh
+++ b/venv-activate.sh
@@ -22,49 +22,7 @@
 
 # wrap in function to allow local variables, since this file will be source'd
 function main() { 
-    local quiet=0
-
-    for arg in "$@"
-    do
-        case $arg in
-            "-q"|"--quiet" )
-               quiet=1
-               ;;
-
-            "-h"|"--help" )
-               echo "venv-activate.sh:  Enter the Mycroft virtual environment"
-               echo "Usage:"
-               echo "   source venv-activate.sh"
-               echo "or"
-               echo "   . venv-activate.sh"
-               echo ""
-               echo "Options:"
-               echo "   -q | --quiet    Don't show instructions."
-               echo "   -h | --help    Show help."
-               return 0
-               ;;
-
-            *)
-               echo "ERROR:  Unrecognized option: $@"
-               return 1
-               ;;
-       esac
-    done
-
-    if [ "$0" == "$BASH_SOURCE" ] ; then
-        # Prevent running in script then exiting immediately
-        echo "ERROR: Invoke with 'source venv-activate.sh' or '. venv-activate.sh'"
-    else
-        local SRC_DIR="$( builtin cd "$( dirname "${BASH_SOURCE}" )" ; pwd -P )"
-        source ${SRC_DIR}/.venv/bin/activate
-        
-        # Provide an easier to find "mycroft-" prefixed command.
-        unalias mycroft-venv-activate 2>/dev/null
-        alias mycroft-venv-deactivate="deactivate && unalias mycroft-venv-deactivate 2>/dev/null && alias mycroft-venv-activate=\"source '${SRC_DIR}/venv-activate.sh'\""
-        if [ $quiet -eq 0 ] ; then
-            echo "Entering Mycroft virtual environment.  Run 'mycroft-venv-deactivate' to exit"
-        fi
-    fi
+   echo "Not entering Python VENV"
 }
 
 main $@
-- 
2.21.0