-
Notifications
You must be signed in to change notification settings - Fork 30
/
install.sh
86 lines (67 loc) · 2.64 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
82
83
84
85
86
#!/bin/bash
# Save the current directory
CURRENT_DIR=$(pwd)
VENV_ACTIVE=false
echo -e "\e[34m[Allor]\e[0m: Searching for Python environments."
if [ -d "../../venv" ]; then
echo -e "\e[34m[Allor]\e[0m: Found venv Python environment."
cd ../..
# Check if the activate script exists in the venv
if [ -f "venv/bin/activate" ]; then
# Activate the virtual environment
source venv/bin/activate
VENV_ACTIVE=true
# Go back to the original directory
cd $CURRENT_DIR
else
echo -e "\e[31m[Allor]\e[0m: Activation script not found."
exit 1
fi
elif command -v python3 &> /dev/null; then
printf "\e[34m[Allor]\e[0m: Only the system Python environment is detected. Should this be used for Allor dependencies? (y/N): "
read answer
[[ $answer =~ ^[yY] ]] || echo -e "\e[31m[Allor]\e[0m: None of the Python environments were found." && exit 1
else
echo -e "\e[31m[Allor]\e[0m: None of the Python environments were found."
exit 1
fi
if [ -f "requirements.txt" ]; then
echo -e "\e[34m[Allor]\e[0m: Install dependencies from the requirements.txt file."
pip install -r requirements.txt --no-warn-script-location --quiet --disable-pip-version-check
else
echo -e "\e[31m[Allor]\e[0m: requirements.txt not found in the current directory."
exit 1
fi
if command -v git >/dev/null 2>&1; then
echo -e "\e[34m[Allor]\e[0m: Git found."
# Check if the current directory is a git repository
if [ ! -d ".git" ]; then
echo -e "\e[34m[Allor]\e[0m: This directory is not a git repository. Initializing a new repository."
git init -b main
git remote add origin https://github.com/Nourepide/ComfyUI-Allor
git pull origin master
else
echo -e "\e[34m[Allor]\e[0m: This directory is already a git repository."
fi
else
echo -e "\e[34m[Allor]\e[0m: Git is not installed. Using GitPython instead."
# Run a Python script that uses GitPython to do the same thing
python -c '
import git
from git import Repo
from pathlib import Path
# Check if the current directory is a git repository
if not (Path(".git").exists() or Path(".git").is_dir()):
print("\033[94m[Allor]\033[0m: This directory is not a git repository. Initializing a new repository.")
repo = Repo.init(initial_branch='main')
origin = repo.create_remote("origin", "https://github.com/Nourepide/ComfyUI-Allor")
origin.fetch("main")
repo.git.reset("--hard", "origin/main")
else:
print("\033[94m[Allor]\033[0m: This directory is already a git repository.")
'
fi
if [ $VENV_ACTIVE ]; then
deactivate
fi
echo -e "\e[32m[Allor]\e[0m: Install complete successful."