summaryrefslogtreecommitdiffstats
path: root/meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2019-04-05 14:41:54 +0000
committerKhem Raj <raj.khem@gmail.com>2019-04-06 08:22:22 -0700
commitfb097550fdc5e8a7de6bdceb87d8aa161b94eb06 (patch)
tree73a0e690aee2c7923e4531ac92eba0076fc105a2 /meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch
parent47f4a924102d014fcd5e68170b98392cfa1f5f44 (diff)
downloadmeta-openembedded-fb097550fdc5e8a7de6bdceb87d8aa161b94eb06.tar.gz
mycroft: Initial commit
Mycroft is an open source speech assistant. It traditionally runs inside Python virtual env and installs all of the pip and native packages and programs that is needs at setup. This generally includes a native gcc build for some of the binaries in the pip packages. This patch adds Mycroft support and edits the source to remove the Python venv usage so we can just run in standard Python world. This allows us to use the preinstalled Python packages where avaliable and avoid installing too much on the target at runtime. At the moment we still require a few simple Python packages to be installed but we don't requrie any target compilation. Hopefully in the future we can remove all of the runtime install requirements by adding all the Python packages to the rootFS pre-boot and setting up the other files/directories as required during the build process. This patch also adds two systemd services. The first will setup mycroft on boot, the second will start the mycroft voice assistant. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch')
-rw-r--r--meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch192
1 files changed, 192 insertions, 0 deletions
diff --git a/meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch b/meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch
new file mode 100644
index 0000000000..c03bccd3da
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/mycroft/files/0001-Remove-python-venv.patch
@@ -0,0 +1,192 @@
1From 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