From d7bf3f7d7b4207571f1c9327daf84ffd0066b121 Mon Sep 17 00:00:00 2001 From: Damian Stewart Date: Thu, 1 Dec 2022 19:35:21 +0100 Subject: [PATCH] make `.sh`/`.bat` files inside `installer/` non executable (#1664) * make binary installer executables non-executable inside the repo * update docs to match previous commit --- .../BUILDING_BINARY_INSTALLERS.md | 85 +++++++++++++++++++ installer/create_installers.sh | 5 +- installer/{install.bat => install.bat.in} | 2 +- installer/{install.sh => install.sh.in} | 31 ++++--- installer/{invoke.bat => invoke.bat.in} | 0 installer/{invoke.sh => invoke.sh.in} | 0 6 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 docs/installation/BUILDING_BINARY_INSTALLERS.md rename installer/{install.bat => install.bat.in} (99%) rename installer/{install.sh => install.sh.in} (89%) rename installer/{invoke.bat => invoke.bat.in} (100%) rename installer/{invoke.sh => invoke.sh.in} (100%) mode change 100755 => 100644 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. diff --git a/installer/create_installers.sh b/installer/create_installers.sh index 833ae82239..479823881a 100755 --- a/installer/create_installers.sh +++ b/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/installer/install.bat b/installer/install.bat.in similarity index 99% rename from installer/install.bat rename to installer/install.bat.in index 9f6934e128..8246e146fa 100644 --- a/installer/install.bat +++ b/installer/install.bat.in @@ -140,7 +140,7 @@ 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 -copy installer\invoke.bat .\invoke.bat +copy installer\invoke.bat.in .\invoke.bat echo ***** Installed invoke launcher script ****** @rem more cleanup diff --git a/installer/install.sh b/installer/install.sh.in similarity index 89% rename from installer/install.sh rename to installer/install.sh.in index 8e1e9185b3..35014df281 100644 --- a/installer/install.sh +++ b/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,29 @@ 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 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" -cp installer/invoke.sh . +cp installer/invoke.sh.in ./invoke.sh +chmod a+x ./invoke.sh echo -e "\n***** Installed invoke launcher script ******\n" # more cleanup @@ -227,6 +228,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/installer/invoke.bat b/installer/invoke.bat.in similarity index 100% rename from installer/invoke.bat rename to installer/invoke.bat.in diff --git a/installer/invoke.sh b/installer/invoke.sh.in old mode 100755 new mode 100644 similarity index 100% rename from installer/invoke.sh rename to installer/invoke.sh.in