2022-12-11 05:37:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
set -e
|
|
|
|
|
2023-12-23 14:16:05 +00:00
|
|
|
BCYAN="\033[1;36m"
|
|
|
|
BYELLOW="\033[1;33m"
|
|
|
|
BGREEN="\033[1;32m"
|
|
|
|
BRED="\033[1;31m"
|
|
|
|
RED="\033[31m"
|
|
|
|
RESET="\033[0m"
|
2022-12-11 05:37:08 +00:00
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
function git_show {
|
2024-02-02 00:23:01 +00:00
|
|
|
git show -s --format=oneline --abbrev-commit "$1" | cat
|
2023-12-10 02:08:23 +00:00
|
|
|
}
|
|
|
|
|
2024-02-09 04:16:09 +00:00
|
|
|
if [[ ! -z "${VIRTUAL_ENV}" ]]; then
|
2024-02-02 00:06:43 +00:00
|
|
|
# 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
|
|
|
|
echo -e "${BRED}A virtual environment is activated. Please deactivate it before proceeding.${RESET}"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
2023-12-10 02:08:23 +00:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2023-12-09 02:03:47 +00:00
|
|
|
VERSION=$(
|
|
|
|
cd ..
|
2024-01-01 00:05:39 +00:00
|
|
|
python3 -c "from invokeai.version import __version__ as version; print(version)"
|
2023-12-09 02:03:47 +00:00
|
|
|
)
|
2023-12-23 14:16:05 +00:00
|
|
|
VERSION="v${VERSION}"
|
2023-12-10 03:29:01 +00:00
|
|
|
|
2024-02-09 04:22:37 +00:00
|
|
|
if [[ ! -z ${CI} ]]; then
|
|
|
|
echo
|
|
|
|
echo -e "${BCYAN}CI environment detected${RESET}"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
2023-12-10 03:29:01 +00:00
|
|
|
echo -e "${BGREEN}HEAD${RESET}:"
|
2024-02-02 00:23:01 +00:00
|
|
|
git_show HEAD
|
2023-12-10 02:08:23 +00:00
|
|
|
echo
|
|
|
|
|
2023-12-23 14:16:05 +00:00
|
|
|
# ---------------------- FRONTEND ----------------------
|
|
|
|
|
|
|
|
pushd ../invokeai/frontend/web >/dev/null
|
|
|
|
echo "Installing frontend dependencies..."
|
|
|
|
echo
|
|
|
|
pnpm i --frozen-lockfile
|
|
|
|
echo
|
2023-12-31 23:41:34 +00:00
|
|
|
if [[ ! -z ${CI} ]]; then
|
|
|
|
echo "Building frontend without checks..."
|
2023-12-23 14:16:05 +00:00
|
|
|
# In CI, we have already done the frontend checks and can just build
|
|
|
|
pnpm vite build
|
|
|
|
else
|
2023-12-31 23:41:34 +00:00
|
|
|
echo "Running checks and building frontend..."
|
2023-12-23 14:16:05 +00:00
|
|
|
# This runs all the frontend checks and builds
|
|
|
|
pnpm build
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
popd
|
|
|
|
|
|
|
|
# ---------------------- BACKEND ----------------------
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Building wheel..."
|
|
|
|
echo
|
|
|
|
|
|
|
|
# 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
|
2024-01-01 00:05:39 +00:00
|
|
|
if [[ $(python3 -c 'from importlib.util import find_spec; print(find_spec("build") is None)') == "True" ]]; then
|
2023-12-23 14:16:05 +00:00
|
|
|
pip install --user build
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf ../build
|
|
|
|
|
2024-01-01 00:05:39 +00:00
|
|
|
python3 -m build --outdir dist/ ../.
|
2023-12-23 14:16:05 +00:00
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# ----------------------
|
|
|
|
|
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
|
|
|
# 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
|
2024-02-02 00:25:23 +00:00
|
|
|
cp install.bat.in InvokeAI-Installer/install.bat
|
2022-12-11 05:37:08 +00:00
|
|
|
cp WinLongPathsEnabled.reg InvokeAI-Installer/
|
|
|
|
|
2023-12-23 14:16:05 +00:00
|
|
|
FILENAME=InvokeAI-installer-$VERSION.zip
|
|
|
|
|
2023-01-28 21:55:28 +00:00
|
|
|
# Zip everything up
|
2023-12-31 23:41:34 +00:00
|
|
|
zip -r ${FILENAME} InvokeAI-Installer
|
2023-12-23 14:16:05 +00:00
|
|
|
|
2024-02-09 04:33:21 +00:00
|
|
|
echo
|
|
|
|
echo -e "${BGREEN}Built installer: ./${FILENAME}${RESET}"
|
|
|
|
echo -e "${BGREEN}Built PyPi distribution: ./dist${RESET}"
|
|
|
|
|
2023-12-31 23:41:34 +00:00
|
|
|
# clean up, but only if we are not in a github action
|
|
|
|
if [[ -z ${CI} ]]; then
|
|
|
|
echo
|
2024-02-09 04:33:29 +00:00
|
|
|
echo "Cleaning up intermediate build files..."
|
|
|
|
rm -rf InvokeAI-Installer tmp ../invokeai/frontend/web/dist/
|
2023-12-23 14:16:05 +00:00
|
|
|
fi
|
2022-12-11 05:37:08 +00:00
|
|
|
|
2023-12-31 23:41:34 +00:00
|
|
|
if [[ ! -z ${CI} ]]; then
|
|
|
|
echo
|
|
|
|
echo "Setting GitHub action outputs..."
|
|
|
|
echo "INSTALLER_FILENAME=${FILENAME}" >>$GITHUB_OUTPUT
|
|
|
|
echo "INSTALLER_PATH=installer/${FILENAME}" >>$GITHUB_OUTPUT
|
2023-12-23 14:16:05 +00:00
|
|
|
echo "DIST_PATH=installer/dist/" >>$GITHUB_OUTPUT
|
|
|
|
fi
|
2022-12-11 05:37:08 +00:00
|
|
|
|
|
|
|
exit 0
|