-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
58 lines (50 loc) · 1.63 KB
/
install.sh
File metadata and controls
58 lines (50 loc) · 1.63 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
#!/bin/bash
# Check if requirements.txt exists
if [[ ! -f "requirements.txt" ]]; then
echo "requirements.txt file not found!"
exit 1
fi
echo "Install all dependencies..."
# Get the number of lines (packages) in requirements.txt
total_packages=$(wc -l < "requirements.txt")
current_package=0
failed_packages=()
# Function to show progress
show_progress() {
local progress=$((current_package * 100 / total_packages))
local done=$((progress * 4 / 10))
local left=$((40 - done))
local fill=$(printf "%${done}s")
local empty=$(printf "%${left}s")
printf "\rInstalling dependencies: [${fill// /#}${empty// /-}] ${progress}%%"
}
# Install each package listed in requirements.txt
while IFS= read -r package
do
if [[ ! -z "$package" ]]; then
# Extract the package name without version number
package_name=$(echo "$package" | cut -d'=' -f1 | cut -d'<' -f1 | cut -d'>' -f1 | cut -d' ' -f1)
pip install "$package" &> /dev/null
if [[ $? -ne 0 ]]; then
failed_packages+=("$package_name")
fi
((current_package++))
show_progress
fi
done < "requirements.txt"
# Finish the progress bar
show_progress
echo -e "\nAll dependencies processed."
# Report failed packages
if [[ ${#failed_packages[@]} -ne 0 ]]; then
echo "The following packages failed to install:"
for pkg in "${failed_packages[@]}"; do
echo "- $pkg"
done
echo "Hint: Try installing the failed packages separately without using version numbers:"
for pkg in "${failed_packages[@]}"; do
echo "pip install $pkg"
done
else
echo "All packages installed successfully."
fi