mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-14 05:58:18 +03:00
1-click installer and updater. Uses micromamba to install git and conda into a contained environment (if necessary) before running the normal installation script (#1519)
Hi, This PR enables a user to install this project without requiring them to have anaconda or git pre-installed. This reduces unnecessary friction for users who aren't programmers or very technical. If a user already has anaconda or git pre-installed, these scripts will just pass-through and won't affect them. Honestly, it's just more straightforward for a user to use. :) ## Current installation process for a user: 1. Install Anaconda 2. Install Git 3. Run the commands for a git pull (on Windows) 4. Run the webui script ## Suggested new process (for Windows and Linux): 1. Download the `install.bat` or `install.sh` script for their OS (linked below, or better, from a release on your project) 2. Run the script That's it. Main improvement: The user doesn't need to have python/anaconda/git pre-installed. This reduces unnecessary friction for non-technical users. ## 1-click Installers: * Windows: https://raw.githubusercontent.com/cmdr2/hlky-webui/master/installer/install.bat * Linux: https://raw.githubusercontent.com/cmdr2/hlky-webui/master/installer/install.sh ----- I've tested this on Windows x64 and Linux x64. I've tested this with and without Anaconda pre-installed. I've also tested it works if the installer gets interrupted mid-way, and needs to be re-run. **Disclosure:** I'm the author of the cmdr2 UI and 1-click installer (https://github.com/cmdr2/stable-diffusion-ui). We use a similar approach and it's been working quite well (~2k installs/day) for over 1.5 months. None of the support issue have been due to this bootstrapping process, but rather due to the usual pip failures, VPN issues, bad system config etc. ## How it works: 1. This script will install git and conda (if not found on the system PATH) using `micromamba` (an 8mb static-linked single-file binary, conda replacement). The micromamba binary will be downloaded if necessary using curl. For users who already have git and python, this step will be skipped. 2. Next, it'll checkout the project's git repo, if necessary. On Linux, it'll download and run the [linux-sd.sh](https://raw.githubusercontent.com/JoshuaKimsey/Linux-StableDiffusion-Script/main/linux-sd.sh) script, like how the installation guide suggests. 3. Finally, it'll start `webui.cmd` on Windows. On Linux, the linux-sd.sh script takes care of this step. After installation, users can continue running `webui.cmd` or `webui.sh` directly. It'll use either the git/python/conda that was installed through this installer, or the user's existing git/python/conda installation. ## Next steps (if you wish to adopt this) If you're willing, then the next steps are: 1. Merging this PR will get the installer scripts into the `installer` folder 2. Uploading the installer files to a GitHub release, or using the upload links inside this PR 3. Updating the README with the download links for the installer. I can submit the PR for the README, if you're interested. If you're interested in this, I'd definitely suggest phasing this in gradually, maybe suggested as an easier alternative on the docs, until it is judged stable to use. Thanks! :) # Checklist: - [y] I have changed the base branch to `dev` - [y] I have performed a self-review of my own code - [y] I have commented my code in hard-to-understand areas - [y] I have made corresponding changes to the documentation
This commit is contained in:
commit
711555b68b
28
installer/create_installers.sh
Normal file
28
installer/create_installers.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# For developers only! Not for users!
|
||||
# This creates the installer zip files that will be distributed to users
|
||||
# It packs install.{sh,bat} along with a readme, and ensures that the user
|
||||
# has the install script inside a new empty folder (after unzipping),
|
||||
# otherwise the git repo will extract into whatever folder the script is in.
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
# make the installer zip for linux and mac
|
||||
rm -rf sygil
|
||||
mkdir -p sygil
|
||||
cp install.sh sygil
|
||||
cp readme.txt sygil
|
||||
|
||||
zip -r sygil-linux.zip sygil
|
||||
zip -r sygil-mac.zip sygil
|
||||
|
||||
# make the installer zip for windows
|
||||
rm -rf sygil
|
||||
mkdir -p sygil
|
||||
cp install.bat sygil
|
||||
cp readme.txt sygil
|
||||
|
||||
zip -r sygil-windows.zip sygil
|
||||
|
||||
echo "The installer zips are ready to be distributed.."
|
96
installer/install.bat
Normal file
96
installer/install.bat
Normal file
@ -0,0 +1,96 @@
|
||||
@echo off
|
||||
|
||||
@rem This script will install git and conda (if not found on the PATH variable)
|
||||
@rem using micromamba (an 8mb static-linked single-file binary, conda replacement).
|
||||
@rem For users who already have git and conda, this step will be skipped.
|
||||
|
||||
@rem Then, it'll run the webui.cmd file to continue with the installation as usual.
|
||||
|
||||
@rem This enables a user to install this project without manually installing conda and git.
|
||||
|
||||
echo "Installing Sygil WebUI.."
|
||||
echo.
|
||||
|
||||
@rem config
|
||||
set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba
|
||||
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
||||
set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe
|
||||
set REPO_URL=https://github.com/Sygil-Dev/sygil-webui.git
|
||||
@rem Change the download URL to Sygil repo's release URL
|
||||
@rem We need to mirror micromamba.exe, because the official download URL uses tar.bz2 compression
|
||||
@rem which Windows can't unzip natively.
|
||||
@rem https://mamba.readthedocs.io/en/latest/installation.html#windows
|
||||
set umamba_exists=F
|
||||
|
||||
@rem figure out whether git and conda needs to be installed
|
||||
if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
||||
|
||||
set PACKAGES_TO_INSTALL=
|
||||
|
||||
call conda --version >.tmp1 2>.tmp2
|
||||
if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda
|
||||
|
||||
call git --version >.tmp1 2>.tmp2
|
||||
if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git
|
||||
|
||||
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2
|
||||
if "%ERRORLEVEL%" EQU "0" set umamba_exists=T
|
||||
|
||||
@rem (if necessary) install git and conda into a contained environment
|
||||
if "%PACKAGES_TO_INSTALL%" NEQ "" (
|
||||
@rem download micromamba
|
||||
if "%umamba_exists%" == "F" (
|
||||
echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe"
|
||||
|
||||
mkdir "%MAMBA_ROOT_PREFIX%"
|
||||
call curl -L "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe"
|
||||
|
||||
@rem test the mamba binary
|
||||
echo Micromamba version:
|
||||
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version
|
||||
)
|
||||
|
||||
@rem create the installer env
|
||||
if not exist "%INSTALL_ENV_DIR%" (
|
||||
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" create -y --prefix "%INSTALL_ENV_DIR%"
|
||||
)
|
||||
|
||||
echo "Packages to install:%PACKAGES_TO_INSTALL%"
|
||||
|
||||
call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL%
|
||||
|
||||
if not exist "%INSTALL_ENV_DIR%" (
|
||||
echo "There was a problem while installing%PACKAGES_TO_INSTALL% using micromamba. Cannot continue."
|
||||
pause
|
||||
exit /b
|
||||
)
|
||||
)
|
||||
|
||||
set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
||||
|
||||
@rem get the repo (and load into the current directory)
|
||||
if not exist ".git" (
|
||||
call git config --global init.defaultBranch master
|
||||
call git init
|
||||
call git remote add origin %REPO_URL%
|
||||
call git fetch
|
||||
call git checkout origin/master -ft
|
||||
)
|
||||
|
||||
@rem activate the base env
|
||||
call conda activate
|
||||
|
||||
@rem make the models dir
|
||||
mkdir models\ldm\stable-diffusion-v1
|
||||
|
||||
@rem install the project
|
||||
call webui.cmd
|
||||
|
||||
@rem finally, tell the user that they need to download the ckpt
|
||||
echo.
|
||||
echo "Now you need to install the weights for the stable diffusion model."
|
||||
echo "Please follow the steps related to models weights at https://sd-webui.github.io/stable-diffusion-webui/docs/1.windows-installation.html#cloning-the-repo to complete the installation"
|
||||
|
||||
@rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually.
|
||||
|
||||
pause
|
90
installer/install.sh
Executable file
90
installer/install.sh
Executable file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script will install git and conda (if not found on the PATH variable)
|
||||
# using micromamba (an 8mb static-linked single-file binary, conda replacement).
|
||||
# For users who already have git and conda, this step will be skipped.
|
||||
|
||||
# Then, it'll run the webui.cmd file to continue with the installation as usual.
|
||||
|
||||
# This enables a user to install this project without manually installing conda and git.
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
echo "Installing Sygil WebUI.."
|
||||
echo ""
|
||||
|
||||
OS_ARCH=$(uname -m)
|
||||
case "${OS_ARCH}" in
|
||||
x86_64*) OS_ARCH="64";;
|
||||
arm64*) OS_ARCH="aarch64";;
|
||||
*) echo "Unknown system architecture: $OS_ARCH! This script runs only on x86_64 or arm64" && exit
|
||||
esac
|
||||
|
||||
# config
|
||||
export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba"
|
||||
INSTALL_ENV_DIR="$(pwd)/installer_files/env"
|
||||
MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/linux-${OS_ARCH}/latest"
|
||||
umamba_exists="F"
|
||||
|
||||
# figure out whether git and conda needs to be installed
|
||||
if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi
|
||||
|
||||
PACKAGES_TO_INSTALL=""
|
||||
|
||||
if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi
|
||||
if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi
|
||||
|
||||
if "$MAMBA_ROOT_PREFIX/micromamba" --version &>/dev/null; then umamba_exists="T"; fi
|
||||
|
||||
# (if necessary) install git and conda into a contained environment
|
||||
if [ "$PACKAGES_TO_INSTALL" != "" ]; then
|
||||
# download micromamba
|
||||
if [ "$umamba_exists" == "F" ]; then
|
||||
echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba"
|
||||
|
||||
mkdir -p "$MAMBA_ROOT_PREFIX"
|
||||
curl -L "$MICROMAMBA_DOWNLOAD_URL" | tar -xvj bin/micromamba -O > "$MAMBA_ROOT_PREFIX/micromamba"
|
||||
|
||||
chmod u+x "$MAMBA_ROOT_PREFIX/micromamba"
|
||||
|
||||
# test the mamba binary
|
||||
echo "Micromamba version:"
|
||||
"$MAMBA_ROOT_PREFIX/micromamba" --version
|
||||
fi
|
||||
|
||||
# create the installer env
|
||||
if [ ! -e "$INSTALL_ENV_DIR" ]; then
|
||||
"$MAMBA_ROOT_PREFIX/micromamba" create -y --prefix "$INSTALL_ENV_DIR"
|
||||
fi
|
||||
|
||||
echo "Packages to install:$PACKAGES_TO_INSTALL"
|
||||
|
||||
"$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL
|
||||
|
||||
if [ ! -e "$INSTALL_ENV_DIR" ]; then
|
||||
echo "There was a problem while initializing micromamba. Cannot continue."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi
|
||||
|
||||
CONDA_BASEPATH=$(conda info --base)
|
||||
source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script)
|
||||
|
||||
conda activate
|
||||
|
||||
# run the installer script for linux
|
||||
curl "https://raw.githubusercontent.com/JoshuaKimsey/Linux-StableDiffusion-Script/main/linux-sd.sh" > linux-sd.sh
|
||||
chmod u+x linux-sd.sh
|
||||
|
||||
./linux-sd.sh
|
||||
|
||||
# tell the user that they need to download the ckpt
|
||||
WEIGHTS_DOC_URL="https://sd-webui.github.io/stable-diffusion-webui/docs/2.linux-installation.html#initial-start-guide"
|
||||
|
||||
echo ""
|
||||
echo "Now you need to install the weights for the stable diffusion model."
|
||||
echo "Please follow the steps at $WEIGHTS_DOC_URL to complete the installation"
|
||||
|
||||
# it would be nice if the weights downloaded automatically, and didn't need the user to do this manually.
|
11
installer/readme.txt
Normal file
11
installer/readme.txt
Normal file
@ -0,0 +1,11 @@
|
||||
Sygil WebUI
|
||||
|
||||
Project homepage: https://github.com/Sygil-Dev/sygil-webui
|
||||
|
||||
Installation on Windows:
|
||||
Please double-click the 'install.bat' file (while keeping it inside the sygil folder).
|
||||
|
||||
Installation on Linux:
|
||||
Please open the terminal, and run './install.sh' (while keeping it inside the sygil folder).
|
||||
|
||||
After installation, please run the 'webui.cmd' file (on Windows) or 'webui.sh' file (on Linux/Mac) to start Sygil.
|
@ -31,7 +31,11 @@ IF EXIST custom-conda-path.txt (
|
||||
FOR /F %%i IN (custom-conda-path.txt) DO set v_custom_path=%%i
|
||||
)
|
||||
|
||||
set v_paths=%ProgramData%\miniconda3
|
||||
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
||||
set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
|
||||
|
||||
set v_paths=%INSTALL_ENV_DIR%
|
||||
set v_paths=%v_paths%;%ProgramData%\miniconda3
|
||||
set v_paths=%v_paths%;%USERPROFILE%\miniconda3
|
||||
set v_paths=%v_paths%;%ProgramData%\anaconda3
|
||||
set v_paths=%v_paths%;%USERPROFILE%\anaconda3
|
||||
|
8
webui.sh
8
webui.sh
@ -24,6 +24,9 @@ ENV_MODIFIED=$(date -r $ENV_FILE "+%s")
|
||||
ENV_MODIFED_FILE=".env_updated"
|
||||
ENV_UPDATED=0
|
||||
|
||||
INSTALL_ENV_DIR="$(pwd)/../installer_files/env" # since linux-sd.sh clones the repo into a subfolder
|
||||
if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi
|
||||
|
||||
# Models used for upscaling
|
||||
GFPGAN_MODEL="https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth"
|
||||
LATENT_DIFFUSION_REPO="https://github.com/devilismyfriend/latent-diffusion.git"
|
||||
@ -50,6 +53,11 @@ conda_env_setup () {
|
||||
CUSTOM_CONDA_PATH=$(cat custom-conda-path.txt)
|
||||
fi
|
||||
|
||||
# If a custom conda isn't specified, and the installer downloaded conda for the user, then use that
|
||||
if [ -f "$INSTALL_ENV_DIR/etc/profile.d/conda.sh" ] && [ "$CUSTOM_CONDA_PATH" == "" ]; then
|
||||
. "$INSTALL_ENV_DIR/etc/profile.d/conda.sh"
|
||||
fi
|
||||
|
||||
# If custom path is set above, try to setup conda environment
|
||||
if [ -f "${CUSTOM_CONDA_PATH}/etc/profile.d/conda.sh" ]; then
|
||||
. "${CUSTOM_CONDA_PATH}/etc/profile.d/conda.sh"
|
||||
|
Loading…
Reference in New Issue
Block a user