Permalink
Browse files

Switch to using virtualenv for most python deps.

  * We continue using system installs of scipy and numpy, since they are super slow to build.
  * supervisor runs our scripts as root directly; using sudo makes it impossible for supervisor to kill them.
  * joust.sh re-runs itself with sudo if it _wasn't_ started as root.
  • Loading branch information...
mbabinski-at-google committed Sep 27, 2017
1 parent 63c34fc commit 7bc2aaab622f4c2d309c28bfadb85836cbcca5ab
Showing with 30 additions and 15 deletions.
  1. +1 −1 conf/supervisor/conf.d/joust.conf
  2. +6 −1 joust.sh
  3. +23 −13 setup.sh
@@ -1,6 +1,6 @@
[program:joustmania]
command=/home/pi/JoustMania/joust.sh
user=pi
user=root
directory=/home/pi/JoustMania/
autorestart=true
startretries=1000
View
@@ -1,5 +1,10 @@
#!/bin/bash
if [ $UID -ne 0 ]; then
echo "Not root. Using sudo."
exec sudo $0
fi
export HOME="/home/pi/JoustMania"
export PYTHONPATH="/home/pi/psmoveapi/build/"
sudo /usr/bin/python3.6 /home/pi/JoustMania/piparty.py
/home/pi/JoustMania/venv/bin/python3.6 /home/pi/JoustMania/piparty.py
View
@@ -6,8 +6,9 @@ export DEBIAN_FRONTEND=noninteractive
#update OS
sudo cp -v conf/sources.list /etc/apt/sources.list || exit -1
sudo cp -v conf/apt.conf /etc/apt/apt.conf.d/10joustmania-conf || exit -1
sudo apt-get update -y
sudo apt-get dist-upgrade -y
sudo apt-get update -y || exit -1
sudo apt-get upgrade -y || exit -1
sudo apt-get dist-upgrade -y || exit -1
cd /home/pi
#TODO: remove pyaudio and dependencies
@@ -16,25 +17,33 @@ sudo apt-get install -y \
python3.6 python3.6-dev python3-pip \
python3-pkg-resources python3-setuptools libdpkg-perl \
libsdl1.2-dev libsdl-mixer1.2-dev libsdl-sound1.2-dev \
libportmidi-dev \
libportmidi-dev portaudio19-dev \
libsdl-image1.2-dev libsdl-ttf2.0-dev \
bluez python3-pyaudio \
supervisor \
cmake \
libblas-dev liblapack-dev \
bluez supervisor cmake ffmpeg \
libudev-dev swig libbluetooth-dev \
alsa-utils alsa-tools libasound2-dev || exit -1
sudo apt-get remove -y python3-pygame
sudo apt-get install -y -t buster libasound2-dev libasound2 python3-numpy python3-scipy
sudo python3.6 -m pip install --upgrade virtualenv || exit -1
sudo python3.6 -m pip install psutil flask Flask-WTF pyalsaaudio pydub pygame || exit -1
#install components for psmoveapi
sudo apt-get install -y \
build-essential \
libv4l-dev libopencv-dev \
libudev-dev libbluetooth-dev \
python3-dev swig3.0 || exit -1
python3.6-dev swig3.0 || exit -1
VENV=$HOME/JoustMania/venv
# We install nearly all python deps in the virtualenv to avoid concflicts with system, except
# numpy and scipy because they take forever to build.
sudo apt-get install -y -t buster libasound2-dev libasound2 python3-numpy python3-scipy
sudo python3.6 -m pip install --upgrade virtualenv || exit -1
# Rebuilding this is pretty cheap, so just do it every time.
rm -rf $VENV
/usr/bin/python3.6 -m virtualenv --system-site-packages $VENV || exit -1
PYTHON=$VENV/bin/python3.6
$PYTHON -m pip install --ignore-installed psutil flask Flask-WTF pyalsaaudio pydub pygame pyaudio || exit -1
#install psmoveapi
git clone --recursive git://github.com/thp/psmoveapi.git
@@ -68,4 +77,5 @@ OLD='env_reset'
NEW='env_keep += "PYTHONPATH"'
sudo sed -i -e "s/$OLD/$NEW/g" /etc/sudoers
sudo reboot
# Pause a second before rebooting so we can see all the output from this script.
(sleep 1; sudo reboot) &

0 comments on commit 7bc2aaa

Please sign in to comment.