Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vidalnt committed Sep 8, 2024
1 parent 19965c1 commit 73ec412
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 49 deletions.
53 changes: 4 additions & 49 deletions run-applio.sh
Original file line number Diff line number Diff line change
@@ -1,54 +1,9 @@
#!/bin/sh
printf "\033]0;Applio\007"

if ! dpkg -s python3.10-venv > /dev/null 2>&1; then
echo "Installing python3.10-venv..."
sudo apt-get update
sudo apt-get install -y python3.10-venv
fi

if ! command -v python > /dev/null 2>&1 && ! command -v python3 > /dev/null 2>&1; then
echo "Error: Python or Python 3 not found. Please install one of them."
exit 1
fi

if [ ! -d ".venv" ]; then
echo "Error: Virtual environment not found. Please run the installer first."
exit 1
fi

echo "Checking if python exists"
if command -v python3.10 > /dev/null 2>&1; then
PYTHON_EXECUTABLE=$(which python3.10)
echo "Using python3.10"
elif command -v python3 > /dev/null 2>&1; then
PYTHON_EXECUTABLE=$(which python3)
echo "Using python3"
elif command -v python > /dev/null 2>&1; then
PYTHON_EXECUTABLE=$(which python)
echo "Using python"
else
echo "Error: Unable to find a suitable Python version."
exit 1
fi

PYTHON_HOME=$(dirname "$PYTHON_EXECUTABLE")

CURRENT_HOME=$(grep "^home =" .venv/pyvenv.cfg | cut -d "=" -f 2 | xargs)

if [ "$CURRENT_HOME" != "$PYTHON_HOME" ]; then
sed -i "s|home =.*|home = $PYTHON_HOME|" .venv/pyvenv.cfg
VENV_PATH=$(realpath .venv)
find "$VENV_PATH/bin/" -type f -exec sed -i "0,/^VIRTUAL_ENV=/s|VIRTUAL_ENV=.*|VIRTUAL_ENV='$VENV_PATH'|" {} \;
else
echo "Home path in .venv/pyvenv.cfg is already up-to-date"
fi

. .venv/bin/activate

export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0

export PYTORCH_ENABLE_MPS_FALLBACK=1
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
clear

"$PYTHON_EXECUTABLE" app.py --open
python app.py --open
50 changes: 50 additions & 0 deletions setup-venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh
printf "\033]0;Applio\007"

if ! dpkg -s python3.10-venv > /dev/null 2>&1; then
echo "Installing python3.10-venv..."
sudo apt-get update
sudo apt-get install -y python3.10-venv
fi

if ! command -v python > /dev/null 2>&1 && ! command -v python3 > /dev/null 2>&1; then
echo "Error: Python or Python 3 not found. Please install one of them."
exit 1
fi

if [ ! -d ".venv" ]; then
echo "Error: Virtual environment not found. Please run the installer first."
exit 1
fi

venv_dir=".venv"

if command -v python3.10 > /dev/null 2>&1; then
python_exe=$(which python3.10)
echo "Using python3.10"
elif command -v python3 > /dev/null 2>&1; then
python_exe=$(which python3)
echo "Using python3"
elif command -v python > /dev/null 2>&1; then
python_exe=$(which python)
echo "Using python"
else
echo "Error: Unable to find a suitable Python version."
exit 1
fi

python_home=$(dirname "$python_exe")
python_prefix=$(dirname "$python_home")
python_exec_prefix="$python_prefix"

sed -i 's/\r$//' "$venv_dir/pyvenv.cfg"
sed -i "s|^home =.*|home = $python_home|" "$venv_dir/pyvenv.cfg"
sed -i "s|^base-prefix =.*|base-prefix = $python_prefix|" "$venv_dir/pyvenv.cfg"
sed -i "s|^base-exec-prefix =.*|base-exec-prefix = $python_exec_prefix|" "$venv_dir/pyvenv.cfg"
sed -i "s|^base-executable =.*|base-executable = $python_exe|" "$venv_dir/pyvenv.cfg"

current_dir=$(pwd)

find "$venv_dir" -type f -exec sed -i -e 's/\r$//' -e "s|/home/runner/work/Applio/Applio/|$current_dir/|g" -e "s|/.venv/bin/python|/.venv/bin/$(basename $python_exe)|g" {} +

echo "Virtual environment paths fixed."

0 comments on commit 73ec412

Please sign in to comment.