-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.sh
executable file
·55 lines (43 loc) · 1.43 KB
/
setup.sh
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
#!/usr/bin/env bash
# sudo pip install virtualenv
# sudo pip install virtualenvwrapper
proj_name=jsk_hsr_wrs
venv=$HOME/.virtualenvs
var_name=WORKON_HOME
#! check if environment exists
if [ ! -d $venv ];
then
/bin/echo -e "\e[1;32m[LOG] virtualenv does not exist. new one will be created\e[0m"
if [ ! -d $venv ];
then
/bin/echo -e "\e[1;32m[LOG] creating virtualenv folder at-> "$venv"\e[0m"
mkdir $venv
fi
if [[ -z "${WORKON_HOME}" ]];
then
printf '\n## Python Virtual Environment\n' >> $HOME/.bashrc
echo "export "$var_name=$venv >> $HOME/.bashrc
/bin/echo -e "\e[1;32m[LOG] setting env var ${WORKON_HOME}\e[0m"
fi
if [ ! -f /usr/local/bin/virtualenvwrapper.sh ];
then
/bin/echo -e "\e[1;31m[ERROR] File /usr/local/bin/virtualenvwrapper.sh not found\e[0m"
exit 1
fi
source /usr/local/bin/virtualenvwrapper.sh
else
source /usr/local/bin/virtualenvwrapper.sh
/bin/echo -e "\e[1;32m[LOG] virtualenv exists\e[0m"
fi
if [ ! -d $WORKON_HOME/$proj_name ];
then
/bin/echo -e "\e[1;32m[LOG] creating virtual environment for the project \e[0m"
mkvirtualenv --python=python3 $proj_name
workon $proj_name
source $WORKON_HOME/$proj_name/bin/activate
else
source $WORKON_HOME/$proj_name/bin/activate
fi
/bin/echo -e "\e[1;32m[LOG] installing dependencies\e[0m"
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pip install -r $dir/requirements.txt