-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbootstrap_venv.sh
87 lines (67 loc) · 2.93 KB
/
bootstrap_venv.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
RED="\033[0;31m"
GREEN="\033[0;32m"
CYAN="\033[0;36m"
BROWN="\033[0;33m"
WHITE="\033[0;0m"
VENV_NAME="hottbox-tutorials"
proceed_installation=1
welcome_message(){
printf "\n====================================================================\n"
printf "\n\tWelcome to a series of tutorials on HOTTBOX. \n\n"
printf "This script will prepare a virtual environment for these tutorials. \n"
printf "Here is what is going to happen during this process: \n\n"
printf "1) Use anaconda to create a new venv: ${GREEN}${VENV_NAME}${WHITE} \n\n"
printf "2) Install required packages: \n"
cat requirements.txt
printf "\n\n"
printf "3) Install ipykernel: ${GREEN}${VENV_NAME}${WHITE}\n"
printf "\n====================================================================\n\n"
}
##################################################################
###-------------------- Main --------------------###
##################################################################
welcome_message
printf "Do you want to proceed? (y/n) "
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
if echo "$answer" | grep -iq "^y" ;then
echo -e "\nFingers crossed and start $GREEN :-/ $WHITE"
else
echo -e "\nQuitting $RED :-( $WHITE\n"
proceed_installation=0
fi
###-------- Check if conda installation exists
if [[ ($proceed_installation == 1) ]]; then
printf "\nChecking to see if ${GREEN}anaconda${WHITE} is installed: "
if ! [ -x "$(command -v conda)" ]; then
echo -e "${RED}not installed${WHITE}.\n"
echo -e "You need have ${RED}anaconda${WHITE} to proceed with this script."
echo -e "Abort installation, nothing has been configured.\n"
proceed_installation=0
else
echo -e "${GREEN}yes, it is${WHITE}."
fi
fi
###-------- Environment creation
if [[ ($proceed_installation == 1) ]]; then
conda create --name ${VENV_NAME} python=3.6
source activate ${VENV_NAME}
VENV_HOME="$(which python)"
pip install --upgrade pip
pip install -r requirements.txt
python -m ipykernel install --user --name ${VENV_NAME} --display-name ${VENV_NAME}
printf "\n"
printf "====================================================================\n"
printf "============ ============\n"
printf "============ Working environment is ready ============\n"
printf "============ ============\n"
printf "====================================================================\n"
printf "\n"
printf "1) Python interpreter for '$VENV_NAME' is located in: \n\n\t"
printf "${VENV_HOME}\n\n"
printf "2) The associate ipython kernel (used in the tutorials by default) is located in: \n\n\t"
jupyter kernelspec list | grep "$VENV_NAME"
printf "\n"
printf "3) You can also select this kernel (${VENV_NAME}), if you want to play around in your own notebook.\n\n"
source deactivate
fi