-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·70 lines (57 loc) · 1.8 KB
/
setup.sh
File metadata and controls
executable file
·70 lines (57 loc) · 1.8 KB
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
#!/usr/bin/env bash
#
# setup.sh
# Written by Mark Koh
# 2/24/2017
#
# This script will install apt-get and brew dependencies as well as install autoenv
# which will automatically activate your virtual environment when you `cd` into this directory.
#
# Feel free to update this file with your own os-level dependencies :)
# See if we have either brew or apt-get installed
BREW_CMD=$(which brew)
APT_CMD=$(which apt-get)
if [[ ! -z $BREW_CMD ]]; then
# What to install with `brew`
echo "Installing brew dependencies...";
brew install python3
elif [[ ! -z $APT_CMD ]]; then
# What to install with `apt-get`
echo "Installing python3...";
sudo apt-get install -y python3 python3-pip
else
echo "Neither brew nor apt-get are installed. Exiting..."
exit 1;
fi
echo "Installing virtualenv and autoenv...";
pip3 install virtualenv autoenv
read -p "Bash startup file [~/.bashrc]: " BASHRC
BASHRC=${BASHRC:-~/.bashrc}
BASHRC_ABS=`eval echo ${BASHRC//>}`
# Check if their bash file has autoenv activated in it, if not, see if they want to add it
if ! grep -q "activate.sh" $BASHRC_ABS ; then
read -r -p "Do you want to add autoenv to your $BASHRC (recommended)? [y/n] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "Adding autoenv to $BASHRC...";
echo "# Activate autoenv" >> $BASHRC_ABS
echo "source `which activate.sh`" >> $BASHRC_ABS
echo "cd ." >> $BASHRC_ABS
fi
fi
VENV=.venv
# Create the actual virtualenv
if [ ! -d $VENV ]; then
echo "Creating virtual env..."
virtualenv -p python3 $VENV
fi
# If we have a requirements file, install them reqs
if [ -f requirements.txt ]; then
echo "Installing pip requirements..."
source $VENV/bin/activate
pip3 install -r requirements.txt
fi
echo "
Please run
source $BASHRC
"