-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bash
More file actions
executable file
Β·135 lines (125 loc) Β· 3.68 KB
/
install.bash
File metadata and controls
executable file
Β·135 lines (125 loc) Β· 3.68 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# install.bash v1.5 @ 2024-11-29 - nelbren@nelbren.com
myEcho() {
tag="$1"
printf "$tag${S}\n"
}
colors_set() {
S="\e[0m";E="\e[K";n="$S\e[38;5";N="\e[9";e="\e[7";I="$e;49;9"
A=7m;R=1m;G=2m;Y=3m;nW="$N$A";nR="$N$R";nG="$N$G";nY="$N$Y"
Iw="$I$A";Ir="$I$R";Ig="$I$G";Iy="$I$Y"
}
python_install() {
printf "${nW}Python Install....${S}"
if ! python -V 1>/dev/null 2>/dev/null; then
myEcho ${nR}'Γ'
printf "\n${nY}Please manually install Python (>= 3.12)${S}\n"
exit 1
else
myEcho ${nG}'β'
fi
}
venv_Scripts_fix() {
if [ -r .venv/bin/activate ]; then
if [ ! -d .venv/Scripts ]; then
mkdir .venv/Scripts
fi
ln -s ../bin/activate .venv/Scripts/activate
fi
}
venv_install() {
printf "${nW}Python Venv.......${S}"
if [ ! -r .venv/Scripts/activate ]; then
venv_Scripts_fix
if [ ! -r .venv/Scripts/activate ]; then
myEcho ${nY}'β'
printf "\n${Iw}python -m venv .venv${S}\n"
python -m venv .venv
printf "${nW}Python Venv.......${S}"
venv_Scripts_fix
if [ ! -r .venv/Scripts/activate ]; then
myEcho ${nR}'Γ'
printf "\n${nY}Please manually make my virtual environment! ( python -m venv .venv )${S}\n"
exit 2
else
myEcho ${nG}'β'
fi
else
myEcho ${nG}'β'
fi
else
myEcho ${nG}'β'
fi
}
pip_update() {
source .venv/Scripts/activate
printf "${nW}Pip Updated.......${S}"
if pip list --outdated 2>/dev/null | grep pip 1>/dev/null 2>/dev/null; then
myEcho ${nY}'β'
printf "\n${Iw}python -m pip install --upgrade pip${S}\n"
python -m pip install --upgrade pip
printf "${nW}Pip Updated.......${S}"
if pip list --outdated 2>/dev/null | grep pip 1>/dev/null 2>/dev/null; then
myEcho ${nR}'Γ'
printf "\n${nY}Please manually update pip! ( python -m pip install --upgrade pip )${S}\n"
exit 3
else
myEcho ${nG}'β'
fi
else
myEcho ${nG}'β'
fi
}
module_install() {
module=$1
# /install.bash: line 49: -1: substring expression < 0
len=${#module}
len=$((len - 1))
#module=${module:0:$len}
import=$2
moduleNumber=$3
if [ "$moduleNumber" == "0" ]; then
reporte="${reporte}$module..."
else
reporte="${reporte}, $module..."
fi
if ! python -c "import $import" 1>/dev/null 2>/dev/null; then
reporte="$reporte ${nY}β${S}"
printf "\n${Iw}pip install $module${S}\n"
pip install $module
if ! python -c "import $import" 1>/dev/null 2>/dev/null; then
reporte="${reporte}${nR}Γ${S} ${nY}( pip install $module )${S}"
# exit 3
else
reporte="$reporte ${nG}β${S}"
fi
else
reporte="$reporte ${nG}β${S}"
fi
}
modules_install() {
source .venv/Scripts/activate
reporte="${nW}Python Modules....(${S}"
error=0
moduleNumber=0
while read module comentario import; do
# echo "MODULE->$module IMPORT->$import MODULENUMBER->$moduleNumber"
if [ -z "$import" ]; then
import=$module
fi
module_install $module $import $moduleNumber
moduleNumber=$((moduleNumber + 1))
done < requirements.txt
printf "$reporte) "
if [ "$error" == "0" ]; then
myEcho ${nG}'β'
else
myEcho ${nR}'Γ'
printf "\n${nY}Please manually install the modules! ( pip install -r requirements.txt )${S}"
fi
}
colors_set
python_install
venv_install
pip_update
modules_install