PoweRO/RBC
0
1#!/bin/sh
2printf "\033]0;Installer\007"
3clear
4rm *.bat
5
6# Function to create or activate a virtual environment
7prepare_install() {
8 if [ -d ".venv" ]; then
9 echo "Venv found. This implies Applio has been already installed or this is a broken install"
10 printf "Do you want to execute run-applio.sh? (Y/N): " >&2
11 read -r r
12 r=$(echo "$r" | tr '[:upper:]' '[:lower:]')
13 if [ "$r" = "y" ]; then
14 ./run-applio.sh && exit 1
15 else
16 echo "Ok! The installation will continue. Good luck!"
17 fi
18 . .venv/bin/activate
19 else
20 echo "Creating venv..."
21 requirements_file="requirements.txt"
22 echo "Checking if python exists"
23 if command -v python3.10 > /dev/null 2>&1; then
24 py=$(which python3.10)
25 echo "Using python3.10"
26 else
27 if python --version | grep -qE "3\.(7|8|9|10)\."; then
28 py=$(which python)
29 echo "Using python"
30 else
31 echo "Please install Python3 or 3.10 manually."
32 exit 1
33 fi
34 fi
35
36 $py -m venv .venv
37 . .venv/bin/activate
38 python -m ensurepip
39 # Update pip within the virtual environment
40 pip3 install --upgrade pip
41 echo
42 echo "Installing Applio dependencies..."
43 python -m pip install -r requirements.txt
44 python -m pip uninstall torch torchvision torchaudio -y
45 python -m pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu121
46 finish
47 fi
48}
49
50# Function to finish installation (this should install missing dependencies)
51finish() {
52 # Check if required packages are installed and install them if not
53 if [ -f "${requirements_file}" ]; then
54 installed_packages=$(python -m pip freeze)
55 while IFS= read -r package; do
56 expr "${package}" : "^#.*" > /dev/null && continue
57 package_name=$(echo "${package}" | sed 's/[<>=!].*//')
58 if ! echo "${installed_packages}" | grep -q "${package_name}"; then
59 echo "${package_name} not found. Attempting to install..."
60 python -m pip install --upgrade "${package}"
61 fi
62 done < "${requirements_file}"
63 else
64 echo "${requirements_file} not found. Please ensure the requirements file with required packages exists."
65 exit 1
66 fi
67 clear
68 echo "Applio has been successfully downloaded. Run the file run-applio.sh to run the web interface!"
69 exit 0
70}
71
72# Loop to the main menu
73if [ "$(uname)" = "Darwin" ]; then
74 if ! command -v brew >/dev/null 2>&1; then
75 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
76 else
77 brew install python@3.10
78 export PYTORCH_ENABLE_MPS_FALLBACK=1
79 export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
80 fi
81elif [ "$(uname)" != "Linux" ]; then
82 echo "Unsupported operating system. Are you using Windows...?"
83 echo "If yes, use the batch (.bat) file instead of this one!"
84 exit 1
85fi
86
87prepare_install
88 