2022-12-11 05:37:08 +00:00
@ echo off
setlocal EnableExtensions EnableDelayedExpansion
@ rem This script requires the user to install Python 3.9 or higher. All other
@ rem requirements are downloaded as needed.
@ rem change to the script's directory
PUSHD " %~dp0 "
set " no_cache_dir=--no-cache-dir "
if " %1 " == " use-cache " (
set " no_cache_dir= "
)
@ rem Config
2023-01-01 17:54:45 +00:00
@ rem The version in the next line is replaced by an up to date release number
@ rem when create_installer.sh is run. Change the release number there.
set INVOKEAI_VERSION = latest
2022-12-11 05:37:08 +00:00
set INSTRUCTIONS = https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
set TROUBLESHOOTING = https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting
set PYTHON_URL = https://www.python.org/downloads/windows/
set MINIMUM_PYTHON_VERSION = 3.9.0
set PYTHON_URL = https://www.python.org/downloads/release/python-3109/
set err_msg = An error has occurred and the script could not continue.
@ rem --------------------------- Intro -------------------------------
2022-12-15 20:08:07 +00:00
echo This script will install InvokeAI and its dependencies.
echo .
echo BEFORE YOU START PLEASE MAKE SURE TO DO THE FOLLOWING
2023-01-16 07:38:50 +00:00
echo 1. Install python 3.9 or 3.10. Python version 3.11 and above are
echo not supported at the moment.
2022-12-11 05:37:08 +00:00
echo 2. Double-click on the file WinLongPathsEnabled.reg in order to
echo enable long path support on your system.
2022-12-15 20:08:07 +00:00
echo 3. Install the Visual C++ core libraries.
2023-01-15 00:28:14 +00:00
echo Please download and install the libraries from:
2022-12-11 05:37:08 +00:00
echo https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170
echo .
echo See %INSTRUCTIONS% for more details.
2023-01-16 07:38:50 +00:00
echo .
2022-12-11 05:37:08 +00:00
pause
@ rem ---------------------------- check Python version ---------------
echo ***** Checking and Updating Python *****
call python --version > .tmp1 2 > .tmp2
if %errorlevel% == 1 (
2023-01-16 07:38:50 +00:00
set err_msg = Please install Python 3.10. See %INSTRUCTIONS% for details.
2022-12-11 05:37:08 +00:00
goto err_exit
)
for /f " tokens=2 " %% i in ( .tmp1) do set python_version = %% i
if " %python_version% " == " " (
set err_msg = No python was detected on your system. Please install Python version %MINIMUM_PYTHON_VERSION% or higher. We recommend Python 3.10.9 from %PYTHON_URL%
goto err_exit
)
call : compareVersions %MINIMUM_PYTHON_VERSION% %python_version%
if %errorlevel% == 1 (
set err_msg = Your version of Python is too low. You need at least %MINIMUM_PYTHON_VERSION% but you have %python_version% . We recommend Python 3.10.9 from %PYTHON_URL%
goto err_exit
)
@ rem Cleanup
del /q .tmp1 .tmp2
2023-01-16 07:38:50 +00:00
@ rem -------------- Install and Configure ---------------
2023-01-15 00:28:14 +00:00
2023-01-16 07:38:50 +00:00
call python main.py
2022-12-11 05:37:08 +00:00
@ rem ------------------------ Subroutines ---------------
@ rem routine to do comparison of semantic version numbers
@ rem found at https://stackoverflow.com/questions/15807762/compare-version-numbers-in-batch-file
: compareVersions
: :
: : Compares two version numbers and returns the result in the ERRORLEVEL
: :
: : Returns 1 if version1 > version2
: : 0 if version1 = version2
: : -1 if version1 < version2
: :
: : The nodes must be delimited by . or , or -
: :
: : Nodes are normally strictly numeric, without a 0 prefix. A letter suffix
: : is treated as a separate node
: :
setlocal enableDelayedExpansion
set " v1= %~1 "
set " v2= %~2 "
call : divideLetters v1
call : divideLetters v2
: loop
call : parseNode " %v1% " n1 v1
call : parseNode " %v2% " n2 v2
if %n1% gtr %n2% exit /b 1
if %n1% lss %n2% exit /b -1
if not defined v1 if not defined v2 exit /b 0
if not defined v1 exit /b -1
if not defined v2 exit /b 1
goto : loop
: parseNode version nodeVar remainderVar
for /f " tokens=1* delims=.,- " %% A in ( " %~1 " ) do (
set " %~2 = %% A "
set " %~3 = %% B "
)
exit /b
: divideLetters versionVar
for %% C in ( a b c d e f g h i j k l m n o p q r s t u v w x y z) do set " %~1 =! %~1 : %% C=. %% C! "
exit /b
: err_exit
echo %err_msg%
echo The installer will exit now.
pause
exit /b
2022-12-13 06:15:11 +00:00
pause
2023-01-15 00:28:14 +00:00
: Trim
SetLocal EnableDelayedExpansion
set Params = %*
for /f " tokens=1* " %% a in ( " !Params! " ) do EndLocal & set %1 = %% b
exit /b