mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
55cfb879d0
In other words, build frontend when creating installer. Changes to `create_installer.sh` - If `python` is not in `PATH` but `python3` is, alias them (well, via function). This is needed on some machines to run the installer without symlinking to `python3`. - Make the messages about pushing tags clearer. The script force-pushes, so it's possible to accidentally take destructive action. I'm not sure how to otherwise prevent damage, so I just added a warning. - Print out `pwd` when prompting about being in the `installer` dir. - Rebuild the frontend - if there is already a frontend build, first checks if the user wants to rebuild it. - Checks for existence of `../build` dir before deleting - if the dir doesn't exist, the script errors and exits at this point. - Format and spell check. Other changes: - Ignore `dist/` folder. - Delete `dist/`. **Note: you may need to use `git rm --cached invokeai/app/frontend/web/dist/` if git still wants to track `dist/`.**
123 lines
2.9 KiB
Bash
Executable File
123 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
function is_bin_in_path {
|
|
builtin type -P "$1" &>/dev/null
|
|
}
|
|
|
|
if ! is_bin_in_path python && is_bin_in_path python3; then
|
|
echo "Aliasing python3 to python..."
|
|
function python {
|
|
python3 "$@"
|
|
}
|
|
fi
|
|
|
|
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
|
|
echo "A virtual environment is activated. Please deactivate it before proceeding".
|
|
exit -1
|
|
fi
|
|
|
|
VERSION=$(
|
|
cd ..
|
|
python -c "from invokeai.version import __version__ as version; print(version)"
|
|
)
|
|
PATCH=""
|
|
VERSION="v${VERSION}${PATCH}"
|
|
LATEST_TAG="v3-latest"
|
|
|
|
echo Building installer for version $VERSION
|
|
echo "Be certain that you're in the 'installer' directory before continuing."
|
|
echo "Currently in '$(pwd)'"
|
|
read -p "Press any key to continue, or CTRL-C to exit..."
|
|
|
|
read -e -p "Tag this repo with '${VERSION}' and '${LATEST_TAG}'? Immediately pushes! [n]: " input
|
|
RESPONSE=${input:='n'}
|
|
if [ "$RESPONSE" == 'y' ]; then
|
|
|
|
git push origin :refs/tags/$VERSION
|
|
if ! git tag -fa $VERSION; then
|
|
echo "Existing/invalid tag"
|
|
exit -1
|
|
fi
|
|
|
|
git push origin :refs/tags/$LATEST_TAG
|
|
git tag -fa $LATEST_TAG
|
|
|
|
echo "remember to push --tags!"
|
|
fi
|
|
|
|
# ---------------------- FRONTEND ----------------------
|
|
|
|
function build_frontend {
|
|
echo Building frontend
|
|
pushd ../invokeai/frontend/web
|
|
pnpm i --frozen-lockfile
|
|
pnpm build
|
|
popd
|
|
}
|
|
|
|
if [ -d ../invokeai/frontend/web/dist ]; then
|
|
read -e -p "Frontend build exists. Rebuild? [n]: " input
|
|
RESPONSE=${input:='n'}
|
|
if [ "$RESPONSE" == 'y' ]; then
|
|
build_frontend
|
|
fi
|
|
else
|
|
build_frontend
|
|
fi
|
|
|
|
# ---------------------- BACKEND ----------------------
|
|
|
|
echo Building the wheel
|
|
|
|
# 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
|
|
|
|
if [ -d ../build ]; then
|
|
rm -Rf ../build
|
|
fi
|
|
|
|
python -m build --wheel --outdir dist/ ../.
|
|
|
|
# ----------------------
|
|
|
|
echo Building installer zip files for InvokeAI $VERSION
|
|
|
|
# get rid of any old ones
|
|
rm -f *.zip
|
|
rm -rf InvokeAI-Installer
|
|
|
|
# copy content
|
|
mkdir InvokeAI-Installer
|
|
for f in templates lib *.txt *.reg; do
|
|
cp -r ${f} InvokeAI-Installer/
|
|
done
|
|
|
|
# Move the wheel
|
|
mv dist/*.whl InvokeAI-Installer/lib/
|
|
|
|
# Install scripts
|
|
# Mac/Linux
|
|
cp install.sh.in InvokeAI-Installer/install.sh
|
|
chmod a+x InvokeAI-Installer/install.sh
|
|
|
|
# Windows
|
|
perl -p -e "s/^set INVOKEAI_VERSION=.*/set INVOKEAI_VERSION=$VERSION/" install.bat.in >InvokeAI-Installer/install.bat
|
|
cp WinLongPathsEnabled.reg InvokeAI-Installer/
|
|
|
|
# Zip everything up
|
|
zip -r InvokeAI-installer-$VERSION.zip InvokeAI-Installer
|
|
|
|
# clean up
|
|
rm -rf InvokeAI-Installer tmp dist
|
|
|
|
exit 0
|