This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall.sh
81 lines (70 loc) · 2.1 KB
/
install.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
#!/bin/bash
set -e
echo "[INFO] Starting installation process..."
detect_terminal() {
if [ -n "$TERMUX_VERSION" ]; then
echo "termux"
elif [ "$(uname)" == "Linux" ]; then
if [ -f "/etc/debian_version" ]; then
echo "debian"
elif [ -f "/etc/redhat-release" ]; then
echo "redhat"
else
echo "unknown-linux"
fi
elif [ "$(uname)" == "Darwin" ]; then
echo "macos"
else
echo "unknown"
fi
}
install_python_termux() {
pkg update -y && pkg install python -y
if ! command -v pip3 &> /dev/null; then
echo "[INFO] Installing pip3..."
python3 -m ensurepip
fi
}
install_python_linux() {
sudo apt update -y && sudo apt install python3 python3-pip -y || {
echo "[INFO] Trying alternative methods..."
sudo apt-get install python3 python3-pip -y || sudo yum install python3 python3-pip -y
}
}
install_python_macos() {
if ! command -v brew &> /dev/null; then
echo "[ERROR] Homebrew is not installed. Please install Homebrew first."
exit 1
fi
brew install python3
}
install_dependencies() {
echo "[INFO] Installing Python dependencies..."
pip3 install -r requirements.txt || {
echo "[ERROR] pip installation failed. Retrying with alternative methods..."
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
}
}
terminal=$(detect_terminal)
echo "[INFO] Detected terminal: $terminal"
if [ "$terminal" == "termux" ]; then
install_python_termux
elif [ "$terminal" == "debian" ] || [ "$terminal" == "redhat" ]; then
install_python_linux
elif [ "$terminal" == "macos" ]; then
install_python_macos
else
echo "[ERROR] Unsupported terminal. Exiting."
exit 1
fi
if ! command -v python3 &> /dev/null; then
echo "[ERROR] Python3 could not be installed. Please install it manually."
exit 1
fi
if ! command -v pip3 &> /dev/null; then
echo "[ERROR] pip3 could not be installed. Please install it manually."
exit 1
fi
install_dependencies
echo "[INFO] Installation completed successfully."