1#!/bin/bash -e
2
3SYS_PYTHON=$(which pypy || which pypy3 || which python3 || which python2)
4
5if [ -z $1 ]
6then
7  DEST=vanguardenv
8else
9  DEST=$1
10fi
11
12mkdir -p $DEST
13
14# 1. Install python if needed
15if [ -z "$(which $SYS_PYTHON)" ]
16then
17  echo "We need pypy, pypy3, python3, or python2 to be in the path."
18  echo "If you are on a Debian or Ubuntu system, you can try: "
19  echo " sudo apt-get install pypy python-virtualenv"
20  exit 1
21fi
22
23if [ -z "$(which virtualenv)" ]
24then
25  echo "We need virtualenv to be in the path. If you are on a debian system, try:"
26  echo " sudo apt-get install python-virtualenv"
27  exit 1
28fi
29
30# 2. Initialize virtualenv
31if [ ! -f ${DEST}/bin/activate ]
32then
33  virtualenv --never-download -p $SYS_PYTHON $DEST
34fi
35source ${DEST}/bin/activate
36
37# 3. Install stem+setuptools
38pip install --require-hashes -r requirements.txt
39
40$(basename $SYS_PYTHON) setup.py install
41
42# 4. Inform user what to do
43echo
44echo "If we got this far, everything should be ready!"
45echo
46echo "Run 'source ${DEST}/bin/activate' to start the environment."
47echo "Then run 'vanguards'"
48