From 1dd5644e7adbd54bc9945c122a601d7e66f5986b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 30 Aug 2023 13:09:12 +0530 Subject: [PATCH] Update build.bat and build.sh to create the installers for Windows and Mac/Linux (respectively) --- .gitignore | 4 +- NSIS/sdui.nsi | 22 +++---- build.bat | 94 ++++++++++++++++++--------- build.sh | 46 +++++-------- scripts/Start Stable Diffusion UI.cmd | 2 +- scripts/bootstrap.bat | 9 ++- scripts/start.sh | 2 +- 7 files changed, 99 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index 90bf0a44..993e0a7c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ installer installer.tar dist .idea/* -node_modules/* \ No newline at end of file +node_modules/* +.tmp1 +.tmp2 diff --git a/NSIS/sdui.nsi b/NSIS/sdui.nsi index 5361512f..92bec886 100644 --- a/NSIS/sdui.nsi +++ b/NSIS/sdui.nsi @@ -165,9 +165,9 @@ FunctionEnd ; MUI Settings ;--------------------------------------------------------------------------------------------------------- !define MUI_ABORTWARNING -!define MUI_ICON "cyborg_flower_girl.ico" +!define MUI_ICON "${EXISTING_INSTALLATION_DIR}\installer_files\cyborg_flower_girl.ico" -!define MUI_WELCOMEFINISHPAGE_BITMAP "cyborg_flower_girl.bmp" +!define MUI_WELCOMEFINISHPAGE_BITMAP "${EXISTING_INSTALLATION_DIR}\installer_files\cyborg_flower_girl.bmp" ; Welcome page !define MUI_WELCOMEPAGE_TEXT "This installer will guide you through the installation of Easy Diffusion.$\n$\n\ @@ -176,8 +176,8 @@ Click Next to continue." Page custom MediaPackDialog ; License page -!insertmacro MUI_PAGE_LICENSE "..\LICENSE" -!insertmacro MUI_PAGE_LICENSE "..\CreativeML Open RAIL-M License" +!insertmacro MUI_PAGE_LICENSE "${EXISTING_INSTALLATION_DIR}\LICENSE" +!insertmacro MUI_PAGE_LICENSE "${EXISTING_INSTALLATION_DIR}\CreativeML Open RAIL-M License" ; Directory page !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave" !insertmacro MUI_PAGE_DIRECTORY @@ -210,20 +210,18 @@ ShowInstDetails show ; List of files to be installed Section "MainSection" SEC01 SetOutPath "$INSTDIR" - File "..\CreativeML Open RAIL-M License" - File "..\How to install and run.txt" - File "..\LICENSE" - File "..\scripts\Start Stable Diffusion UI.cmd" + File "${EXISTING_INSTALLATION_DIR}\CreativeML Open RAIL-M License" + File "${EXISTING_INSTALLATION_DIR}\How to install and run.txt" + File "${EXISTING_INSTALLATION_DIR}\LICENSE" + File "${EXISTING_INSTALLATION_DIR}\Start Stable Diffusion UI.cmd" File /r "${EXISTING_INSTALLATION_DIR}\installer_files" File /r "${EXISTING_INSTALLATION_DIR}\sd-ui-files" - SetOutPath "$INSTDIR\installer_files" - File "cyborg_flower_girl.ico" - SetOutPath "$INSTDIR\scripts" File "${EXISTING_INSTALLATION_DIR}\scripts\install_status.txt" - File "..\scripts\on_env_start.bat" + File "${EXISTING_INSTALLATION_DIR}\scripts\on_env_start.bat" File "C:\windows\system32\curl.exe" + File "${EXISTING_INSTALLATION_DIR}\scripts\config.yaml.sample" CreateDirectory "$INSTDIR\models\stable-diffusion" CreateDirectory "$INSTDIR\models\gfpgan" diff --git a/build.bat b/build.bat index 2c7890ee..960e6c1f 100644 --- a/build.bat +++ b/build.bat @@ -1,48 +1,78 @@ @echo off +setlocal enabledelayedexpansion @echo "Hi there, what you are running is meant for the developers of this project, not for users." & echo. -@echo "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file." +@echo "If you only want to use Easy Diffusion, you've downloaded the wrong file." @echo "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation" & echo. @echo "If you are actually a developer of this project, please type Y and press enter" & echo. set /p answer=Are you a developer of this project (Y/N)? if /i "%answer:~,1%" NEQ "Y" exit /b -mkdir dist\win\stable-diffusion-ui\scripts -@REM mkdir dist\linux-mac\stable-diffusion-ui\scripts +@rem verify dependencies +call makensis /VERSION >.tmp1 2>.tmp2 +if "!ERRORLEVEL!" NEQ "0" ( + echo makensis.exe not found! Download it from https://sourceforge.net/projects/nsisbi/files/ and set it on the PATH variable. + pause + exit +) -@rem copy the installer files for Windows +set /p OUT_DIR=Output folder path (will create the installer files inside this, e.g. F:\EasyDiffusion): -copy scripts\on_env_start.bat dist\win\stable-diffusion-ui\scripts\ -copy scripts\bootstrap.bat dist\win\stable-diffusion-ui\scripts\ -copy scripts\config.yaml.sample dist\win\stable-diffusion-ui\scripts\config.yaml -copy "scripts\Start Stable Diffusion UI.cmd" dist\win\stable-diffusion-ui\ -copy LICENSE dist\win\stable-diffusion-ui\ -copy "CreativeML Open RAIL-M License" dist\win\stable-diffusion-ui\ -copy "How to install and run.txt" dist\win\stable-diffusion-ui\ -echo. > dist\win\stable-diffusion-ui\scripts\install_status.txt +mkdir "%OUT_DIR%\scripts" +mkdir "%OUT_DIR%\installer_files" -@rem copy the installer files for Linux and Mac +set BASE_DIR=%cd% -@REM copy scripts\on_env_start.sh dist\linux-mac\stable-diffusion-ui\scripts\ -@REM copy scripts\bootstrap.sh dist\linux-mac\stable-diffusion-ui\scripts\ -@REM copy scripts\start.sh dist\linux-mac\stable-diffusion-ui\ -@REM copy LICENSE dist\linux-mac\stable-diffusion-ui\ -@REM copy "CreativeML Open RAIL-M License" dist\linux-mac\stable-diffusion-ui\ -@REM copy "How to install and run.txt" dist\linux-mac\stable-diffusion-ui\ -@REM echo. > dist\linux-mac\stable-diffusion-ui\scripts\install_status.txt +@rem STEP 1: copy the installer files for Windows -@rem make the zip - -cd dist\win -call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-windows.zip -cd ..\.. - -@REM cd dist\linux-mac -@REM call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-linux.zip -@REM call powershell Compress-Archive -Path stable-diffusion-ui -DestinationPath ..\stable-diffusion-ui-mac.zip -@REM cd ..\.. - -echo "Build ready. Upload the zip files inside the 'dist' folder." +copy "%BASE_DIR%\scripts\on_env_start.bat" "%OUT_DIR%\scripts\" +copy "%BASE_DIR%\scripts\config.yaml.sample" "%OUT_DIR%\scripts\config.yaml.sample" +copy "%BASE_DIR%\scripts\Start Stable Diffusion UI.cmd" "%OUT_DIR%\" +copy "%BASE_DIR%\LICENSE" "%OUT_DIR%\" +copy "%BASE_DIR%\CreativeML Open RAIL-M License" "%OUT_DIR%\" +copy "%BASE_DIR%\How to install and run.txt" "%OUT_DIR%\" +copy "%BASE_DIR%\NSIS\cyborg_flower_girl.ico" "%OUT_DIR%\installer_files\" +copy "%BASE_DIR%\NSIS\cyborg_flower_girl.bmp" "%OUT_DIR%\installer_files\" +echo. > "%OUT_DIR%\scripts\install_status.txt" +echo ---- +echo Basic files ready. Verify the files in %OUT_DIR%, then press Enter to initialize the environment, or close to quit. +echo ---- pause + +@rem STEP 2: Initialize the environment with git, python and conda + +cd /d "%OUT_DIR%\" +call "%BASE_DIR%\scripts\bootstrap.bat" + +echo ---- +echo Environment ready. Verify the environment, then press Enter to download the necessary packages, or close to quit. +echo ---- +pause + +@rem STEP 3: Download the packages and create a working installation + +cd /d "%OUT_DIR%\" +start "Install Easy Diffusion" /D "%OUT_DIR%" "Start Stable Diffusion UI.cmd" + +echo ---- +echo Installation in progress (in a new window). Once complete, verify the installation, then press Enter to create an installer from these files, or close to quit. +echo ---- +pause + +@rem STEP 4: Build the installer from a working installation + +cd /d "%OUT_DIR%\" + +echo ^^!define EXISTING_INSTALLATION_DIR "%OUT_DIR%" > nsisconf.nsh +call makensis /NOCD /V4 "%BASE_DIR%\NSIS\sdui.nsi" + +echo ---- +if "!ERRORLEVEL!" EQU "0" ( + echo Installer built successfully at %OUT_DIR% +) else ( + echo Installer failed to build at %OUT_DIR% +) +echo ---- +pause \ No newline at end of file diff --git a/build.sh b/build.sh index dfb8f420..3fd724a1 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash printf "Hi there, what you are running is meant for the developers of this project, not for users.\n\n" -printf "If you only want to use the Stable Diffusion UI, you've downloaded the wrong file.\n" +printf "If you only want to use Easy Diffusion, you've downloaded the wrong file.\n" printf "Please download and follow the instructions at https://github.com/easydiffusion/easydiffusion#installation \n\n" printf "If you are actually a developer of this project, please type Y and press enter\n\n" @@ -11,40 +11,30 @@ case $yn in * ) exit;; esac -# mkdir -p dist/win/stable-diffusion-ui/scripts -mkdir -p dist/linux-mac/stable-diffusion-ui/scripts - -# copy the installer files for Windows - -# cp scripts/on_env_start.bat dist/win/stable-diffusion-ui/scripts/ -# cp scripts/bootstrap.bat dist/win/stable-diffusion-ui/scripts/ -# cp "scripts/Start Stable Diffusion UI.cmd" dist/win/stable-diffusion-ui/ -# cp LICENSE dist/win/stable-diffusion-ui/ -# cp "CreativeML Open RAIL-M License" dist/win/stable-diffusion-ui/ -# cp "How to install and run.txt" dist/win/stable-diffusion-ui/ -# echo "" > dist/win/stable-diffusion-ui/scripts/install_status.txt +mkdir -p dist/linux-mac/easy-diffusion/scripts # copy the installer files for Linux and Mac -cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/ -cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/ -cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/ -cp scripts/config.yaml.sample dist/linux-mac/stable-diffusion-ui/scripts/config.yaml -cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/ -cp LICENSE dist/linux-mac/stable-diffusion-ui/ -cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/ -cp "How to install and run.txt" dist/linux-mac/stable-diffusion-ui/ -echo "" > dist/linux-mac/stable-diffusion-ui/scripts/install_status.txt +cp scripts/on_env_start.sh dist/linux-mac/easy-diffusion/scripts/ +cp scripts/bootstrap.sh dist/linux-mac/easy-diffusion/scripts/ +cp scripts/functions.sh dist/linux-mac/easy-diffusion/scripts/ +cp scripts/config.yaml.sample dist/linux-mac/easy-diffusion/scripts/config.yaml.sample +cp scripts/start.sh dist/linux-mac/easy-diffusion/ +cp LICENSE dist/linux-mac/easy-diffusion/ +cp "CreativeML Open RAIL-M License" dist/linux-mac/easy-diffusion/ +cp "How to install and run.txt" dist/linux-mac/easy-diffusion/ +echo "" > dist/linux-mac/easy-diffusion/scripts/install_status.txt + +# set the permissions +chmod u+x dist/linux-mac/easy-diffusion/scripts/on_env_start.sh +chmod u+x dist/linux-mac/easy-diffusion/scripts/bootstrap.sh +chmod u+x dist/linux-mac/easy-diffusion/start.sh # make the zip -# cd dist/win -# zip -r ../stable-diffusion-ui-windows.zip stable-diffusion-ui -# cd ../.. - cd dist/linux-mac -zip -r ../stable-diffusion-ui-linux.zip stable-diffusion-ui -zip -r ../stable-diffusion-ui-mac.zip stable-diffusion-ui +zip -r ../Easy-Diffusion-Linux.zip easy-diffusion +zip -r ../Easy-Diffusion-Mac.zip easy-diffusion cd ../.. echo "Build ready. Upload the zip files inside the 'dist' folder." diff --git a/scripts/Start Stable Diffusion UI.cmd b/scripts/Start Stable Diffusion UI.cmd index 5dfb43f7..a10302ee 100644 --- a/scripts/Start Stable Diffusion UI.cmd +++ b/scripts/Start Stable Diffusion UI.cmd @@ -15,7 +15,7 @@ if exist "on_sd_start.bat" ( echo download. This will not work. echo. echo Recommended: Please close this window and download the installer from - echo https://stable-diffusion-ui.github.io/docs/installation/ + echo https://easydiffusion.github.io/docs/installation/ echo. echo ================================================================================ echo. diff --git a/scripts/bootstrap.bat b/scripts/bootstrap.bat index 8c1069c8..366f109e 100644 --- a/scripts/bootstrap.bat +++ b/scripts/bootstrap.bat @@ -14,6 +14,8 @@ set LEGACY_INSTALL_ENV_DIR=%cd%\installer set MICROMAMBA_DOWNLOAD_URL=https://github.com/easydiffusion/easydiffusion/releases/download/v1.1/micromamba.exe set umamba_exists=F +set PYTHONHOME= + set OLD_APPDATA=%APPDATA% set OLD_USERPROFILE=%USERPROFILE% set APPDATA=%cd%\installer_files\appdata @@ -22,15 +24,12 @@ set USERPROFILE=%cd%\profile @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= +set PACKAGES_TO_INSTALL=git python=3.8.5 if not exist "%LEGACY_INSTALL_ENV_DIR%\etc\profile.d\conda.sh" ( - if not exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda python=3.8.5 + if not exist "%INSTALL_ENV_DIR%\etc\profile.d\conda.sh" 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 diff --git a/scripts/start.sh b/scripts/start.sh index b309216a..be5004a2 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -11,7 +11,7 @@ if [ -f "on_sd_start.bat" ]; then echo download. This will not work. echo echo Recommended: Please close this window and download the installer from - echo https://stable-diffusion-ui.github.io/docs/installation/ + echo https://easydiffusion.github.io/docs/installation/ echo echo ================================================================================ echo