diff --git a/binary_installer/create_installers.sh b/binary_installer/create_installers.sh index 833ae82239..479823881a 100755 --- a/binary_installer/create_installers.sh +++ b/binary_installer/create_installers.sh @@ -9,7 +9,8 @@ read -p "Press any key to continue, or CTRL-C to exit..." # make the installer zip for linux and mac rm -rf InvokeAI mkdir -p InvokeAI -cp install.sh InvokeAI +cp install.sh.in InvokeAI/install.sh +chmod a+x InvokeAI/install.sh cp readme.txt InvokeAI zip -r InvokeAI-linux.zip InvokeAI @@ -18,7 +19,7 @@ zip -r InvokeAI-mac.zip InvokeAI # make the installer zip for windows rm -rf InvokeAI mkdir -p InvokeAI -cp install.bat InvokeAI +cp install.bat.in InvokeAI/install.bat cp readme.txt InvokeAI cp WinLongPathsEnabled.reg InvokeAI diff --git a/binary_installer/install.bat b/binary_installer/install.bat.in similarity index 97% rename from binary_installer/install.bat rename to binary_installer/install.bat.in index c4bbdd2358..aaf71160af 100644 --- a/binary_installer/install.bat +++ b/binary_installer/install.bat.in @@ -140,7 +140,11 @@ set err_msg=----- InvokeAI setup failed ----- .venv\Scripts\python -m pip install %no_cache_dir% --no-warn-script-location -e . if %errorlevel% neq 0 goto err_exit +<<<<<<< HEAD:binary_installer/install.bat copy binary_installer\invoke.bat .\invoke.bat +======= +copy installer\invoke.bat.in .\invoke.bat +>>>>>>> main:binary_installer/install.bat.in echo ***** Installed invoke launcher script ****** @rem more cleanup diff --git a/binary_installer/install.sh b/binary_installer/install.sh.in similarity index 88% rename from binary_installer/install.sh rename to binary_installer/install.sh.in index b0c3286c07..c080884903 100644 --- a/binary_installer/install.sh +++ b/binary_installer/install.sh.in @@ -1,5 +1,9 @@ #!/usr/bin/env bash +# ensure we're in the correct folder in case user's CWD is somewhere else +scriptdir=$(dirname "$0") +cd "$scriptdir" + set -euo pipefail IFS=$'\n\t' @@ -22,6 +26,8 @@ function _err_exit { # This enables a user to install this project without manually installing git or Python +echo -e "\n***** Installing InvokeAI into $(pwd)... *****\n" + export no_cache_dir="--no-cache-dir" if [ $# -ge 1 ]; then if [ "$1" = "use-cache" ]; then @@ -29,10 +35,6 @@ if [ $# -ge 1 ]; then fi fi -echo "$no_cache_dir" - -echo -e "\n***** Installing InvokeAI... *****\n" - OS_NAME=$(uname -s) case "${OS_NAME}" in @@ -80,19 +82,17 @@ if [ "$OS_NAME" == "darwin" ] && [ "$OS_ARCH" == "arm64" ]; then fi # config -echo "USING development BRANCH. REMEMBER TO CHANGE TO main BEFORE RELEASE" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${MAMBA_OS_NAME}-${MAMBA_ARCH}/latest" RELEASE_URL=https://github.com/invoke-ai/InvokeAI -# RELEASE_SOURCEBALL=/archive/refs/heads/main.tar.gz -# RELEASE_SOURCEBALL=/archive/refs/heads/test-installer.tar.gz -RELEASE_SOURCEBALL=/archive/refs/heads/development.tar.gz +RELEASE_SOURCEBALL=/archive/refs/heads/main.tar.gz PYTHON_BUILD_STANDALONE_URL=https://github.com/indygreg/python-build-standalone/releases/download if [ "$OS_NAME" == "darwin" ]; then PYTHON_BUILD_STANDALONE=20221002/cpython-3.10.7+20221002-${PY_ARCH}-apple-darwin-install_only.tar.gz elif [ "$OS_NAME" == "linux" ]; then PYTHON_BUILD_STANDALONE=20221002/cpython-3.10.7+20221002-${PY_ARCH}-unknown-linux-gnu-install_only.tar.gz fi +echo "INSTALLING $RELEASE_SOURCEBALL FROM $RELEASE_URL" PACKAGES_TO_INSTALL="" @@ -192,28 +192,33 @@ echo -e "We're running under" _err_exit $? _err_msg _err_msg="\n----- pip update failed -----\n" -.venv/bin/python3 -m pip install "$no_cache_dir" --no-warn-script-location --upgrade pip wheel +.venv/bin/python3 -m pip install $no_cache_dir --no-warn-script-location --upgrade pip _err_exit $? _err_msg -echo -e "\n***** Updated pip and wheel *****\n" +echo -e "\n***** Updated pip *****\n" _err_msg="\n----- requirements file copy failed -----\n" cp binary_installer/py3.10-${OS_NAME}-"${OS_ARCH}"-${CD}-reqs.txt requirements.txt _err_exit $? _err_msg _err_msg="\n----- main pip install failed -----\n" -.venv/bin/python3 -m pip install "$no_cache_dir" --no-warn-script-location -r requirements.txt +.venv/bin/python3 -m pip install $no_cache_dir --no-warn-script-location -r requirements.txt _err_exit $? _err_msg echo -e "\n***** Installed Python dependencies *****\n" _err_msg="\n----- InvokeAI setup failed -----\n" -.venv/bin/python3 -m pip install "$no_cache_dir" --no-warn-script-location -e . +.venv/bin/python3 -m pip install $no_cache_dir --no-warn-script-location -e . _err_exit $? _err_msg echo -e "\n***** Installed InvokeAI *****\n" +<<<<<<< HEAD:binary_installer/install.sh cp binary_installer/invoke.sh . +======= +cp installer/invoke.sh.in ./invoke.sh +chmod a+x ./invoke.sh +>>>>>>> main:binary_installer/install.sh.in echo -e "\n***** Installed invoke launcher script ******\n" # more cleanup @@ -227,6 +232,8 @@ deactivate echo -e "\n***** Finished downloading models *****\n" -echo "All done! Run the command './invoke.sh' to start InvokeAI." +echo "All done! Run the command" +echo " \"$scriptdir/invoke.sh\"" +echo "to start InvokeAI." read -p "Press any key to exit..." exit diff --git a/binary_installer/invoke.bat b/binary_installer/invoke.bat.in similarity index 100% rename from binary_installer/invoke.bat rename to binary_installer/invoke.bat.in diff --git a/binary_installer/invoke.sh b/binary_installer/invoke.sh.in old mode 100755 new mode 100644 similarity index 100% rename from binary_installer/invoke.sh rename to binary_installer/invoke.sh.in diff --git a/docs/installation/BUILDING_BINARY_INSTALLERS.md b/docs/installation/BUILDING_BINARY_INSTALLERS.md new file mode 100644 index 0000000000..d4b4004e7c --- /dev/null +++ b/docs/installation/BUILDING_BINARY_INSTALLERS.md @@ -0,0 +1,85 @@ +# How to build "binary" installers (InvokeAI-mac/windows/linux_on_*.zip) + +## 1. Ensure `installers/requirements.in` is correct + +and up to date on the branch to be installed. + +## 2. Run `pip-compile` on each platform. + +On each target platform, in the branch that is to be installed, and +inside the InvokeAI git root folder, run the following commands: + +```commandline +conda activate invokeai # or however you activate python +pip install pip-tools +pip-compile --allow-unsafe --generate-hashes --output-file=installer/.txt installer/requirements.in +``` +where `.txt` is whichever of +```commandline +py3.10-darwin-arm64-mps-reqs.txt +py3.10-darwin-x86_64-reqs.txt +py3.10-linux-x86_64-cuda-reqs.txt +py3.10-windows-x86_64-cuda-reqs.txt +``` +matches the current OS and architecture. +> There is no way to cross-compile these. They must be done on a system matching the target OS and arch. + +## 3. Set github repository and branch + +Once all reqs files have been collected and committed **to the branch +to be installed**, edit `installer/install.sh.in` and `installer/install.bat.in` so that `RELEASE_URL` +and `RELEASE_SOURCEBALL` point to the github repo and branch that is +to be installed. + +For example, to install `main` branch of `InvokeAI`, they should be +set as follows: + +`install.sh.in`: +```commandline +RELEASE_URL=https://github.com/invoke-ai/InvokeAI +RELEASE_SOURCEBALL=/archive/refs/heads/main.tar.gz +``` + +`install.bat.in`: +```commandline +set RELEASE_URL=https://github.com/invoke-ai/InvokeAI +set RELEASE_SOURCEBALL=/archive/refs/heads/main.tar.gz +``` + +Or, to install `damians-cool-feature` branch of `damian0815`, set them +as follows: + +`install.sh.in`: +```commandline +RELEASE_URL=https://github.com/damian0815/InvokeAI +RELEASE_SOURCEBALL=/archive/refs/heads/damians-cool-feature.tar.gz +``` + +`install.bat.in`: +```commandline +set RELEASE_URL=https://github.com/damian0815/InvokeAI +set RELEASE_SOURCEBALL=/archive/refs/heads/damians-cool-feature.tar.gz +``` + +The branch and repo specified here **must** contain the correct reqs +files. The installer zip files **do not** contain requirements files, +they are pulled from the specified branch during the installation +process. + +## 4. Create zip files. + +cd into the `installers/` folder and run +`./create_installers.sh`. This will create +`InvokeAI-mac_on_.zip`, +`InvokeAI-windows_on_.zip` and +`InvokeAI-linux_on_.zip`. These files can be distributed to end users. + +These zips will continue to function as installers for all future +pushes to those branches, as long as necessary changes to +`requirements.in` are propagated in a timely manner to the +`py3.10-*-reqs.txt` files using pip-compile as outlined in [step +2](#step-2). + +To actually install, users should unzip the appropriate zip file into an empty +folder and run `install.sh` on macOS/Linux or `install.bat` on +Windows.