From bfec10bdfe8a39e2840c1c213463dd6b526c54bc Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 13:17:58 +0530 Subject: [PATCH 01/15] 1-click installer using micromamba to install git and conda into a contained environment (if necessary) before running the normal installation script --- installer/How to create the installers.md | 55 +++++++++++++++++ installer/install.bat | 74 +++++++++++++++++++++++ update.bat | 14 +++++ webui.cmd | 6 +- 4 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 installer/How to create the installers.md create mode 100644 installer/install.bat create mode 100644 update.bat diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md new file mode 100644 index 0000000..bc68626 --- /dev/null +++ b/installer/How to create the installers.md @@ -0,0 +1,55 @@ +**Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. + +This guide explains how to create the zip files that users will use for installing. + +The installer zip contains two files: the script, and the micromamba binary. + +Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). + +# Download micromamba from: +* Windows x64: `curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj bin/micromamba_win_x64.exe` + +* Linux x64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba_linux_x64` +* Linux arm64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba_linux_arm64` + +* Mac x64: `curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba_mac_x64` +* Mac arm64 (M1/Apple Silicon): `curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba_mac_arm64` + +The download link provides tar.bz2 files. + +(source https://mamba.readthedocs.io/en/latest/installation.html) + +# Create the installer +Create the following folder structure, and zip it up. + +For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` and the corresponding `micromamba` binary. + +### Windows x64: +``` +.\install.bat +.\installer_files\micromamba_win_x64.exe +``` + +### Linux x64: +``` +.\install.sh +.\installer_files\micromamba_linux_x64 +``` + +### Linux arm64: +``` +.\install.sh +.\installer_files\micromamba_linux_arm64 +``` + +### Mac x64: +``` +.\install.sh +.\installer_files\micromamba_mac_x64 +``` + +### Mac arm64 (M1/Apple Silicon): +``` +.\install.sh +.\installer_files\micromamba_mac_arm64 +``` diff --git a/installer/install.bat b/installer/install.bat new file mode 100644 index 0000000..7f46e47 --- /dev/null +++ b/installer/install.bat @@ -0,0 +1,74 @@ +@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 Next, it'll checkout the project's git repo, if necessary. +@rem Finally, it'll create the conda environment and preload the models. + +@rem This enables a user to install this project without manually installing conda and git. + +@rem prevent the window from closing after an error +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + +@rem config +set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba +set INSTALL_ENV_DIR=%cd%\installer_files\env +set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe + +@rem figure out whether git and conda needs to be installed +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 + +@rem (if necessary) install git and conda into a contained environment +if "%PACKAGES_TO_INSTALL%" NEQ "" ( + @rem initialize micromamba + if not exist "%MAMBA_ROOT_PREFIX%" ( + mkdir "%MAMBA_ROOT_PREFIX%" + copy "%MICROMAMBA_BINARY_FILE%" "%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% +) + +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%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 https://github.com/cmdr2/hkly-webui.git + call git fetch + call git checkout origin/master -ft +) + +@rem make the models dir +mkdir models\ldm\stable-diffusion-v1 + +@rem install the project +@REM 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. + diff --git a/update.bat b/update.bat new file mode 100644 index 0000000..e81a426 --- /dev/null +++ b/update.bat @@ -0,0 +1,14 @@ +@echo off + +@rem prevent the window from closing after an error +if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) + +set INSTALL_ENV_DIR=%cd%\installer_files\env +set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% + +@rem update the repo +if exist ".git" ( + call git pull +) + +conda env update diff --git a/webui.cmd b/webui.cmd index b0621e4..19d31ad 100644 --- a/webui.cmd +++ b/webui.cmd @@ -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;%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 From 187a3c934f3aa8addec21fe818f4fefc9ebedf63 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 13:23:56 +0530 Subject: [PATCH 02/15] Call the webui cmd from the installer --- installer/install.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/install.bat b/installer/install.bat index 7f46e47..ebb21f4 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -63,7 +63,7 @@ if not exist ".git" ( mkdir models\ldm\stable-diffusion-v1 @rem install the project -@REM call webui.cmd +call webui.cmd @rem finally, tell the user that they need to download the ckpt echo. From 89a9cea83d57f80afb08bd14b50403793e26ab36 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 14:56:50 +0530 Subject: [PATCH 03/15] Linux 1-click installer --- installer/install.bat | 3 +- installer/install.sh | 67 +++++++++++++++++++++++++++++++++++++++++++ webui.sh | 8 ++++++ 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 installer/install.sh diff --git a/installer/install.bat b/installer/install.bat index ebb21f4..aa45bb5 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -4,8 +4,7 @@ @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 Next, it'll checkout the project's git repo, if necessary. -@rem Finally, it'll create the conda environment and preload the models. +@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. diff --git a/installer/install.sh b/installer/install.sh new file mode 100644 index 0000000..f22317b --- /dev/null +++ b/installer/install.sh @@ -0,0 +1,67 @@ +#!/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. + +OS_ARCH=$(uname -m) +case "${OS_ARCH}" in + x86_64*) OS_ARCH="x64";; + arm64*) OS_ARCH="arm64";; + *) 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_BINARY_FILE="$(pwd)/installer_files/micromamba_linux_${OS_ARCH}" + +# figure out whether git and conda needs to be installed +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 ! hash "curl" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL curl"; fi + +# (if necessary) install git and conda into a contained environment +if [ "$PACKAGES_TO_INSTALL" != "" ]; then + # initialize micromamba + if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + mkdir -p "$MAMBA_ROOT_PREFIX" + cp "$MICROMAMBA_BINARY_FILE" "$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 +fi + +if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi + +# 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. diff --git a/webui.sh b/webui.sh index 7fdce43..e079120 100755 --- a/webui.sh +++ b/webui.sh @@ -23,6 +23,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" @@ -49,6 +52,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" From 090146c3a09bae971f7dda29122291ff3f194133 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 15:00:52 +0530 Subject: [PATCH 04/15] Make the linux installer executable --- installer/install.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 installer/install.sh diff --git a/installer/install.sh b/installer/install.sh old mode 100644 new mode 100755 From 799f67ab4f9c7e189c6c406eb1472a04cf1b962b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 15:18:08 +0530 Subject: [PATCH 05/15] Add a pause before the script ends --- installer/install.bat | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index aa45bb5..1472cff 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -8,9 +8,6 @@ @rem This enables a user to install this project without manually installing conda and git. -@rem prevent the window from closing after an error -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - @rem config set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env @@ -71,3 +68,4 @@ echo "Please follow the steps related to models weights at https://sd-webui.gith @rem it would be nice if the weights downloaded automatically, and didn't need the user to do this manually. +pause From 4bc8b37c7309f482ff8d84fd02fad916d2157a3b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 15:45:50 +0530 Subject: [PATCH 06/15] Remove update.bat --- update.bat | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 update.bat diff --git a/update.bat b/update.bat deleted file mode 100644 index e81a426..0000000 --- a/update.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off - -@rem prevent the window from closing after an error -if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit ) - -set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% - -@rem update the repo -if exist ".git" ( - call git pull -) - -conda env update From 5dcee6245a24edd22c8e2748c8342d2512e01de9 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 13 Oct 2022 17:59:50 +0530 Subject: [PATCH 07/15] Point to the official repo; Put a temp pre-PR hack to allow the installer to be tested before the PR is merged --- installer/install.bat | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/installer/install.bat b/installer/install.bat index 1472cff..26dbc33 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -42,6 +42,15 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( 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% + + @rem !! The next 3 lines will be removed before the PR is merged. + @rem !! They are needed so the sd-webui folks can test the installer + @rem !! before the PR is merged. Otherwise webui.cmd won't know that it needs + @rem !! to also check inside %INSTALL_ENV_DIR% + if exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" ( + echo %INSTALL_ENV_DIR% > custom-conda-path.txt + ) + @rem !! Remove the above 3 lines before merging the PR ) set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @@ -50,7 +59,7 @@ set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scrip if not exist ".git" ( call git config --global init.defaultBranch master call git init - call git remote add origin https://github.com/cmdr2/hkly-webui.git + call git remote add origin https://github.com/sd-webui/stable-diffusion-webui.git call git fetch call git checkout origin/master -ft ) From 8de5e6aaba9f8bbb0f20d9e29fc8806e90cc2e1a Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 16:33:08 +0530 Subject: [PATCH 08/15] Download micromamba from the original URL instead of bundling it in the installer; Activate the base environment before running conda commands --- installer/install.bat | 36 ++++++++++++++++++++++++------------ installer/install.sh | 32 +++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 26dbc33..b36f9e5 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -8,12 +8,22 @@ @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_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe +set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe +set REPO_URL=https://github.com/cmdr2/hlky-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 @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 @@ -24,10 +34,12 @@ if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git @rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( - @rem initialize micromamba - if not exist "%MAMBA_ROOT_PREFIX%" ( + @rem download micromamba + if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" ( + echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe" + mkdir "%MAMBA_ROOT_PREFIX%" - copy "%MICROMAMBA_BINARY_FILE%" "%MAMBA_ROOT_PREFIX%\micromamba.exe" + call curl -L "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe" @rem test the mamba binary echo Micromamba version: @@ -43,14 +55,11 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL% - @rem !! The next 3 lines will be removed before the PR is merged. - @rem !! They are needed so the sd-webui folks can test the installer - @rem !! before the PR is merged. Otherwise webui.cmd won't know that it needs - @rem !! to also check inside %INSTALL_ENV_DIR% - if exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" ( - echo %INSTALL_ENV_DIR% > custom-conda-path.txt + if not exist "%INSTALL_ENV_DIR%" ( + echo "There was a problem while installing%PACKAGES_TO_INSTALL% using micromamba. Cannot continue." + pause + exit /b ) - @rem !! Remove the above 3 lines before merging the PR ) set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% @@ -59,11 +68,14 @@ set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scrip if not exist ".git" ( call git config --global init.defaultBranch master call git init - call git remote add origin https://github.com/sd-webui/stable-diffusion-webui.git + 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 diff --git a/installer/install.sh b/installer/install.sh index f22317b..6fd24ef 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -8,31 +8,39 @@ # This enables a user to install this project without manually installing conda and git. +echo "Installing Sygil WebUI.." +echo "" + OS_ARCH=$(uname -m) case "${OS_ARCH}" in - x86_64*) OS_ARCH="x64";; - arm64*) OS_ARCH="arm64";; + 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_BINARY_FILE="$(pwd)/installer_files/micromamba_linux_${OS_ARCH}" +MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/linux-${OS_ARCH}/latest" # 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 ! hash "curl" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL curl"; fi # (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then - # initialize micromamba - if [ ! -e "$MAMBA_ROOT_PREFIX" ]; then + # download micromamba + if [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" + mkdir -p "$MAMBA_ROOT_PREFIX" - cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" + 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:" @@ -47,10 +55,20 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then 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 From bdbf8f8cd30f722ef40be030612f7cbd63944f8c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 16:35:17 +0530 Subject: [PATCH 09/15] Installer docs --- installer/How to create the installers.md | 54 +---------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md index bc68626..8030ff7 100644 --- a/installer/How to create the installers.md +++ b/installer/How to create the installers.md @@ -1,55 +1,5 @@ **Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. -This guide explains how to create the zip files that users will use for installing. +Just distribute the `install.bat` or `install.sh` file. -The installer zip contains two files: the script, and the micromamba binary. - -Micromamba is a single ~8mb binary file, that acts like a package manager (drop-in replacement for conda). - -# Download micromamba from: -* Windows x64: `curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj bin/micromamba_win_x64.exe` - -* Linux x64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba_linux_x64` -* Linux arm64: `curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba_linux_arm64` - -* Mac x64: `curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba_mac_x64` -* Mac arm64 (M1/Apple Silicon): `curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba_mac_arm64` - -The download link provides tar.bz2 files. - -(source https://mamba.readthedocs.io/en/latest/installation.html) - -# Create the installer -Create the following folder structure, and zip it up. - -For Linux/Mac: Make sure the `chmod u+x` permission is granted to `install.sh` and the corresponding `micromamba` binary. - -### Windows x64: -``` -.\install.bat -.\installer_files\micromamba_win_x64.exe -``` - -### Linux x64: -``` -.\install.sh -.\installer_files\micromamba_linux_x64 -``` - -### Linux arm64: -``` -.\install.sh -.\installer_files\micromamba_linux_arm64 -``` - -### Mac x64: -``` -.\install.sh -.\installer_files\micromamba_mac_x64 -``` - -### Mac arm64 (M1/Apple Silicon): -``` -.\install.sh -.\installer_files\micromamba_mac_arm64 -``` +Running that file will download the invokeAI repository into the same folder as the script, and install the required dependencies. From cd99e6d57da6fc109d75889894fc35f897c550b5 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 26 Oct 2022 16:38:32 +0530 Subject: [PATCH 10/15] Add Library\usr\bin to the PATH --- installer/install.bat | 2 +- webui.cmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index b36f9e5..cf650da 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -62,7 +62,7 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( ) ) -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +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" ( diff --git a/webui.cmd b/webui.cmd index 860e222..e1248a9 100644 --- a/webui.cmd +++ b/webui.cmd @@ -32,7 +32,7 @@ IF EXIST custom-conda-path.txt ( ) set INSTALL_ENV_DIR=%cd%\installer_files\env -set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%PATH% +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 From 0c7526313fc4cd0bf653983d2a5cc4e98d1c088c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 19:48:51 +0530 Subject: [PATCH 11/15] Redownload micromamba if the download failed midway; Start the script in the script's directory, not where it was run from --- installer/install.bat | 8 ++++++-- installer/install.sh | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index cf650da..973c6c8 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -15,11 +15,12 @@ echo. 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/cmdr2/hlky-webui.git +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% @@ -32,10 +33,13 @@ 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 not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" ( + if "%umamba_exists%" == "F" ( echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe" mkdir "%MAMBA_ROOT_PREFIX%" diff --git a/installer/install.sh b/installer/install.sh index 6fd24ef..432cd0c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -8,6 +8,8 @@ # This enables a user to install this project without manually installing conda and git. +cd "$(dirname "${BASH_SOURCE[0]}")" + echo "Installing Sygil WebUI.." echo "" @@ -22,6 +24,7 @@ esac 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 @@ -31,10 +34,12 @@ 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 [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + if [ "$umamba_exists" == "F" ]; then echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" mkdir -p "$MAMBA_ROOT_PREFIX" From fef5019bdafcc41b9121420856afb010ad5c6ec6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Nov 2022 09:40:42 +0530 Subject: [PATCH 12/15] create_installers script --- installer/create_installers.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 installer/create_installers.sh diff --git a/installer/create_installers.sh b/installer/create_installers.sh new file mode 100644 index 0000000..38cf140 --- /dev/null +++ b/installer/create_installers.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# 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.." From 2769ec22f2ec2e9e6e30de452bac372f49ae0b26 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Nov 2022 09:44:07 +0530 Subject: [PATCH 13/15] readme.txt for users in the release zip --- installer/How to create the installers.md | 5 ----- installer/readme.txt | 11 +++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 installer/How to create the installers.md create mode 100644 installer/readme.txt diff --git a/installer/How to create the installers.md b/installer/How to create the installers.md deleted file mode 100644 index 8030ff7..0000000 --- a/installer/How to create the installers.md +++ /dev/null @@ -1,5 +0,0 @@ -**Important:** These instructions are for the developers of this project, not for users! The users should use the pre-created zip files for installation. - -Just distribute the `install.bat` or `install.sh` file. - -Running that file will download the invokeAI repository into the same folder as the script, and install the required dependencies. diff --git a/installer/readme.txt b/installer/readme.txt new file mode 100644 index 0000000..d73a027 --- /dev/null +++ b/installer/readme.txt @@ -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. \ No newline at end of file From 9501ab855a73c791a196f18dbd6a412089df26c3 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Nov 2022 09:44:44 +0530 Subject: [PATCH 14/15] Add dev-only warning --- installer/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/installer/install.sh b/installer/install.sh index 432cd0c..19bb64c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -1,5 +1,6 @@ #!/bin/bash +# For developers only! Not for users! # 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. From 96b568ae099d1a97a0392250f74e50a2faeefd31 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Nov 2022 09:45:12 +0530 Subject: [PATCH 15/15] Add dev-only warning --- installer/create_installers.sh | 1 + installer/install.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/create_installers.sh b/installer/create_installers.sh index 38cf140..70290ea 100644 --- a/installer/create_installers.sh +++ b/installer/create_installers.sh @@ -1,5 +1,6 @@ #!/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), diff --git a/installer/install.sh b/installer/install.sh index 19bb64c..432cd0c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -1,6 +1,5 @@ #!/bin/bash -# For developers only! Not for users! # 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.