-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_env.sh
executable file
·54 lines (43 loc) · 1.18 KB
/
init_env.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
#!/bin/bash -e
platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'Darwin' ]]; then
platform='mac'
fi
install_cmd='sudo apt-get install'
if [[ "$platform" == 'mac' ]]; then
install_cmd='brew install'
fi
BASEDIR=`dirname $0`
if ! which python > /dev/null; then
echo -e "Python3 not found! Install? (y/n) \c"
read
if [ "$REPLY" = "y" ]; then
$install_cmd install python3
fi
fi
pip_opt=''
pip_opt='-i http://pypi.douban.com/simple --trusted-host pypi.douban.com'
if ! which virtualenv > /dev/null; then
echo -e "virtualenv not found! Install? (y/n) \c"
read
if [ "$REPLY" = "y" ]; then
pip3 install virtualenv $pip_opt
fi
fi
if [ ! -d "$BASEDIR/ve" ]; then
virtualenv -p python3 $BASEDIR/ve --no-download
echo "Virtualenv created."
fi
source $BASEDIR/ve/bin/activate
cd $BASEDIR
export PYTHONPATH=$PYTHONPATH:.
if [ ! -f "$BASEDIR/ve/updated" -o $BASEDIR/requirements.txt -nt $BASEDIR/ve/updated ]; then
pip install -r $BASEDIR/requirements.txt $pip_opt
touch $BASEDIR/ve/updated
echo "Requirements installed."
fi
pip install ipython jupyterlab $pip_opt
echo "env ok"