-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·104 lines (86 loc) · 2.27 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
set -e
# helped functions
to_lowercase() {
local input="$1"
echo "$input" | tr '[:upper:]' '[:lower:]'
}
check_string_exist() {
local str1="$1"
local arr2=("${@:2}")
for str2 in "${arr2[@]}"; do
if [ "$str1" == "$str2" ]; then
return 0 # Return true if the string exists in the second array
fi
done
return 1 # Return false if the string does not exist in the second array
}
# start setup
clear
if command -v python3 &> /dev/null; then
echo "Python detected, moving forward with setup"
else
echo "Python not detected"
echo "Please install python and rerun setup"
exit 1
fi
echo "Please choose your setup option: "
echo "1) Use virtual environment using Poetry"
echo "2) Use your global space"
read -p "# Input: " option
clear
if [ "$option" -gt 0 ] && [ "$option" -le 2 ]; then
echo "You have chosen $option."
read -p "Confirm (Y/N):" confirm
else
echo "$option is not a valid option."
exit 1
fi
clear
package_name="poetry"
confirmlower=$(to_lowercase "$confirm")
possible_confirm=("y" "n")
if ! check_string_exist "$confirmlower" "${possible_confirm[@]}"; then
echo "$confirmlower is not a valid option."
exit 1
fi
if [ "$confirmlower" == "n" ]; then
echo "Aborted"
exit 0
fi
if [ "$option" -eq 1 ]; then
if pip show "$package_name" &> /dev/null; then
echo "$package_name detected."
else
read -p "$package_name is not installed, and this is needed to proceed. Should we install it? (Y/N):" poetry_confirm
poetry_confirm_lower=$(to_lowercase "$poetry_confirm")
if ! check_string_exist "$poetry_confirm_lower" "${possible_confirm[@]}"; then
echo "$poetry_confirm_lower is not a valid option."
exit 1
fi
if [ "$poetry_confirm_lower" == "y" ]; then
pip install poetry
else
echo "Aborted"
exit 0
fi
fi
poetry config virtualenvs.create true
# install opentoolkit
poetry install
poetry run python -m ipykernel install --user --name=ad-kernel
poetry run init_magic
# Virtual ENV
clear
echo "Success!"
echo "Enter the virtual environment by entering 'poetry shell' and start using Opentoolkit!"
fi
if [ "$option" -eq 2 ]; then
# Global ENV
pip install .
python -m ipykernel install --user --name=ad-kernel
init_magic
clear
echo "Success!"
echo "Start using Opentoolkit!"
fi