2017-11-03 23:22:38 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-03-01 02:49:34 +00:00
|
|
|
# Copyright 2018 Mycroft AI Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2017-11-03 23:22:38 +00:00
|
|
|
|
2018-03-08 22:30:36 +00:00
|
|
|
is_command() { hash "$1" 2>/dev/null; }
|
|
|
|
apt_is_locked() { fuser /var/lib/dpkg/lock >/dev/null 2>&1; }
|
2017-11-07 02:59:30 +00:00
|
|
|
wait_for_apt() {
|
2018-04-20 17:09:53 +00:00
|
|
|
if apt_is_locked; then
|
|
|
|
echo "Waiting to obtain dpkg lock file..."
|
|
|
|
while apt_is_locked; do echo .; sleep 0.5; done
|
|
|
|
fi
|
2017-11-07 02:59:30 +00:00
|
|
|
}
|
2018-03-08 22:30:36 +00:00
|
|
|
vpython() { "$VENV/bin/python" $@; }
|
|
|
|
vpip() { "$VENV/bin/pip" $@; }
|
2017-11-07 02:59:30 +00:00
|
|
|
|
2018-04-20 17:03:43 +00:00
|
|
|
install_tensorflow_armv7l() {
|
2018-04-20 17:09:53 +00:00
|
|
|
maj_min=$(python3 -c "import sys; i = sys.version_info; print(str(i[0]) + str(i[1]))")
|
|
|
|
whl=tensorflow-1.1.0-cp34-cp34m-linux_armv7l.whl
|
|
|
|
ver_whl=${whl//34/$maj_min}
|
2018-04-20 17:03:43 +00:00
|
|
|
|
2018-04-20 17:09:53 +00:00
|
|
|
url=https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.1.0/$whl
|
|
|
|
wget "$url" -O $ver_whl
|
2018-04-20 17:03:43 +00:00
|
|
|
|
|
|
|
vpip install "$ver_whl"
|
|
|
|
vpip uninstall mock || true; vpip install mock
|
2018-04-20 17:09:53 +00:00
|
|
|
rm "$ver_whl"
|
2018-04-20 17:03:43 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 22:30:36 +00:00
|
|
|
#############################################
|
|
|
|
set -e; cd "$(dirname "$0")" # Script Start #
|
|
|
|
#############################################
|
|
|
|
|
|
|
|
VENV=${VENV-$(pwd)/.venv}
|
2017-11-03 23:22:38 +00:00
|
|
|
|
2018-02-21 05:42:04 +00:00
|
|
|
if is_command apt-get; then
|
2017-11-09 03:37:29 +00:00
|
|
|
wait_for_apt
|
2018-05-30 17:19:22 +00:00
|
|
|
sudo apt-get install -y python3-pip libopenblas-dev python3-scipy cython libhdf5-dev python3-h5py portaudio19-dev swig libpulse-dev
|
2018-06-04 20:08:23 +00:00
|
|
|
elif is_command brew; then
|
|
|
|
brew install portaudio
|
2017-11-09 03:37:29 +00:00
|
|
|
fi
|
2017-11-03 23:22:38 +00:00
|
|
|
|
2018-06-13 18:41:48 +00:00
|
|
|
if [ ! -x "$VENV/bin/python" ]; then python3 -m venv "$VENV" --without-pip; fi
|
|
|
|
if [ ! -x "$VENV/bin/pip" ]; then curl https://bootstrap.pypa.io/get-pip.py | vpython; fi
|
2018-02-09 00:43:03 +00:00
|
|
|
|
2017-11-03 23:22:38 +00:00
|
|
|
arch="$(python3 -c 'import platform; print(platform.machine())')"
|
|
|
|
|
2018-04-20 17:03:43 +00:00
|
|
|
if [ "$arch" = "armv7l" ] && ! vpython -c 'import tensorflow' 2>/dev/null; then
|
2018-04-20 17:09:53 +00:00
|
|
|
install_tensorflow_armv7l
|
2017-11-03 23:22:38 +00:00
|
|
|
fi
|
|
|
|
|
2018-03-08 22:30:36 +00:00
|
|
|
vpip install -e runner/
|
|
|
|
vpip install -e .
|
|
|
|
vpip install pocketsphinx # Optional, for comparison
|