This commit is contained in:
Haoming 2026-03-29 20:51:24 +07:00 committed by GitHub
parent 06eabbfdc0
commit d9f2e1e252
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 112 additions and 0 deletions

13
webui-user.sh Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
# export PYTHON=
# export GIT=
# export VENV_DIR=
export TORCH_COMMAND="pip install torch==2.10.0 torchvision==0.25.0"
export COMMANDLINE_ARGS="--uv"
# --skip-python-version-check --skip-torch-cuda-test --skip-version-check --skip-prepare-environment --skip-install
exec "$(dirname "$0")/webui.sh"

99
webui.sh Normal file
View File

@ -0,0 +1,99 @@
#!/usr/bin/env bash
set -e
# Load optional settings
if [ -f "webui.settings.sh" ]; then
source webui.settings.sh
fi
# Defaults
PYTHON="${PYTHON:-python3}"
VENV_DIR="${VENV_DIR:-$(cd "$(dirname "$0")" && pwd)/venv}"
SD_WEBUI_RESTART="tmp/restart"
ERROR_REPORTING="FALSE"
mkdir -p tmp
# Check python
if uv help python >tmp/stdout.txt 2>tmp/stderr.txt; then
:
elif "$PYTHON" -c "" >tmp/stdout.txt 2>tmp/stderr.txt; then
:
else
echo "Couldn't launch python"
goto_show_logs=1
fi
# Check pip
if [ -z "$goto_show_logs" ]; then
if uv help pip >tmp/stdout.txt 2>tmp/stderr.txt; then
:
elif "$PYTHON" -m pip --help >tmp/stdout.txt 2>tmp/stderr.txt; then
:
else
echo "Couldn't launch pip"
goto_show_logs=1
fi
fi
# Venv handling
if [ -z "$goto_show_logs" ]; then
if [ "$VENV_DIR" = "-" ] || [ "$SKIP_VENV" = "1" ]; then
:
else
if [ -x "$VENV_DIR/bin/python" ]; then
:
else
PYTHON_FULLNAME=$("$PYTHON" -c "import sys; print(sys.executable)")
echo "Creating venv in directory $VENV_DIR using python $PYTHON_FULLNAME"
"$PYTHON_FULLNAME" -m venv "$VENV_DIR" >tmp/stdout.txt 2>tmp/stderr.txt || {
echo "Unable to create venv in directory \"$VENV_DIR\""
goto_show_logs=1
}
fi
if [ -z "$goto_show_logs" ]; then
"$VENV_DIR/bin/python" -m pip install --upgrade pip || \
echo "Warning: Failed to upgrade PIP version"
# Activate venv
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
PYTHON="$VENV_DIR/bin/python"
echo "venv $PYTHON"
fi
fi
fi
# Launch
if [ -z "$goto_show_logs" ]; then
"$PYTHON" launch.py "$@"
if [ -f "$SD_WEBUI_RESTART" ]; then
exec "$0" "$@"
fi
exit 0
fi
# Show logs
echo
echo "exit code: $?"
if [ -s tmp/stdout.txt ]; then
echo
echo "stdout:"
cat tmp/stdout.txt
fi
if [ -s tmp/stderr.txt ]; then
echo
echo "stderr:"
cat tmp/stderr.txt
fi
echo
echo "Launch Unsuccessful! Exiting..."
exit 1