2022-12-11 05:37:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
set -e
|
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
BCYAN="\e[1;36m"
|
|
|
|
BYELLOW="\e[1;33m"
|
|
|
|
BGREEN="\e[1;32m"
|
2023-12-10 02:11:44 +00:00
|
|
|
BRED="\e[1;31m"
|
2023-12-10 02:08:23 +00:00
|
|
|
RED="\e[31m"
|
|
|
|
RESET="\e[0m"
|
2022-12-11 05:37:08 +00:00
|
|
|
|
2023-12-09 02:03:47 +00:00
|
|
|
function is_bin_in_path {
|
|
|
|
builtin type -P "$1" &>/dev/null
|
|
|
|
}
|
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
function git_show {
|
|
|
|
git show -s --format='%h %s' $1
|
|
|
|
}
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
echo -e "${BYELLOW}This script must be run from the installer directory!${RESET}"
|
|
|
|
echo "The current working directory is $(pwd)"
|
|
|
|
read -p "If that looks right, press any key to proceed, or CTRL-C to exit..."
|
|
|
|
echo
|
|
|
|
|
2023-12-10 03:02:25 +00:00
|
|
|
# Some machines only have `python3` in PATH, others have `python` - make an alias.
|
2023-12-09 05:49:41 +00:00
|
|
|
# We can use a function to approximate an alias within a non-interactive shell.
|
2023-12-09 02:03:47 +00:00
|
|
|
if ! is_bin_in_path python && is_bin_in_path python3; then
|
|
|
|
function python {
|
|
|
|
python3 "$@"
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
2023-01-30 08:42:27 +00:00
|
|
|
if [[ -v "VIRTUAL_ENV" ]]; then
|
|
|
|
# we can't just call 'deactivate' because this function is not exported
|
|
|
|
# to the environment of this script from the bash process that runs the script
|
2023-12-10 02:11:44 +00:00
|
|
|
echo -e "${BRED}A virtual environment is activated. Please deactivate it before proceeding.${RESET}"
|
2023-01-30 08:42:27 +00:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2023-12-09 02:03:47 +00:00
|
|
|
VERSION=$(
|
|
|
|
cd ..
|
|
|
|
python -c "from invokeai.version import __version__ as version; print(version)"
|
|
|
|
)
|
2023-01-01 17:54:45 +00:00
|
|
|
PATCH=""
|
|
|
|
VERSION="v${VERSION}${PATCH}"
|
2023-12-10 03:29:01 +00:00
|
|
|
|
|
|
|
echo -e "${BGREEN}HEAD${RESET}:"
|
2023-12-10 02:08:23 +00:00
|
|
|
git_show
|
|
|
|
echo
|
|
|
|
|
2023-12-09 02:03:47 +00:00
|
|
|
# ---------------------- FRONTEND ----------------------
|
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
pushd ../invokeai/frontend/web >/dev/null
|
|
|
|
echo
|
|
|
|
echo "Installing frontend dependencies..."
|
|
|
|
echo
|
|
|
|
pnpm i --frozen-lockfile
|
|
|
|
echo
|
|
|
|
echo "Building frontend..."
|
|
|
|
echo
|
|
|
|
pnpm build
|
|
|
|
popd
|
2023-12-09 02:03:47 +00:00
|
|
|
|
|
|
|
# ---------------------- BACKEND ----------------------
|
2023-01-28 21:55:28 +00:00
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
echo
|
|
|
|
echo "Building wheel..."
|
|
|
|
echo
|
2023-01-28 21:55:28 +00:00
|
|
|
|
|
|
|
# install the 'build' package in the user site packages, if needed
|
|
|
|
# could be improved by using a temporary venv, but it's tiny and harmless
|
|
|
|
if [[ $(python -c 'from importlib.util import find_spec; print(find_spec("build") is None)') == "True" ]]; then
|
|
|
|
pip install --user build
|
|
|
|
fi
|
|
|
|
|
2023-12-09 09:33:17 +00:00
|
|
|
rm -rf ../build
|
2023-12-09 02:03:47 +00:00
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
python -m build --wheel --outdir dist/ ../.
|
|
|
|
|
|
|
|
# ----------------------
|
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
echo
|
|
|
|
echo "Building installer zip files for InvokeAI ${VERSION}..."
|
|
|
|
echo
|
2022-12-11 05:37:08 +00:00
|
|
|
|
|
|
|
# get rid of any old ones
|
2023-01-28 21:55:28 +00:00
|
|
|
rm -f *.zip
|
2022-12-11 05:37:08 +00:00
|
|
|
rm -rf InvokeAI-Installer
|
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# copy content
|
|
|
|
mkdir InvokeAI-Installer
|
2023-12-15 16:27:21 +00:00
|
|
|
for f in templates *.txt *.reg; do
|
2023-01-28 21:55:28 +00:00
|
|
|
cp -r ${f} InvokeAI-Installer/
|
|
|
|
done
|
2023-12-15 16:27:21 +00:00
|
|
|
mkdir InvokeAI-Installer/lib
|
|
|
|
cp lib/*.py InvokeAI-Installer/lib
|
2022-12-11 05:37:08 +00:00
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# Move the wheel
|
2023-02-07 21:35:22 +00:00
|
|
|
mv dist/*.whl InvokeAI-Installer/lib/
|
2022-12-11 05:37:08 +00:00
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# Install scripts
|
|
|
|
# Mac/Linux
|
2023-01-30 01:10:51 +00:00
|
|
|
cp install.sh.in InvokeAI-Installer/install.sh
|
|
|
|
chmod a+x InvokeAI-Installer/install.sh
|
2022-12-11 05:37:08 +00:00
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# Windows
|
2023-12-09 02:03:47 +00:00
|
|
|
perl -p -e "s/^set INVOKEAI_VERSION=.*/set INVOKEAI_VERSION=$VERSION/" install.bat.in >InvokeAI-Installer/install.bat
|
2022-12-11 05:37:08 +00:00
|
|
|
cp WinLongPathsEnabled.reg InvokeAI-Installer/
|
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# Zip everything up
|
|
|
|
zip -r InvokeAI-installer-$VERSION.zip InvokeAI-Installer
|
2022-12-11 05:37:08 +00:00
|
|
|
|
|
|
|
# clean up
|
2023-12-16 08:39:29 +00:00
|
|
|
rm -rf InvokeAI-Installer tmp dist ../invokeai/frontend/web/dist/
|
2022-12-11 05:37:08 +00:00
|
|
|
|
|
|
|
exit 0
|