(installer) build .whl and distribute together with the installer; install from bundled .whl by default

This commit is contained in:
Eugene Brodsky 2023-01-28 16:55:28 -05:00
parent 47dbe7bc0d
commit f1f8ce604a
4 changed files with 45 additions and 31 deletions

54
installer/create_installer.sh Normal file → Executable file
View File

@ -1,5 +1,7 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
VERSION=$(cd ..; python -c "from ldm.invoke import __version__ as version; print(version)")
@ -23,38 +25,49 @@ if [ "$RESPONSE" == 'y' ]; then
git tag -fa latest
fi
# ----------------------
echo Building the wheel
if [[ -v "VIRTUAL_ENV" ]]; then deactivate; fi
# 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
python -m build --wheel --outdir dist/ ../.
# ----------------------
echo Building installer zip fles for InvokeAI $VERSION
# get rid of any old ones
rm *.zip
rm -f *.zip
rm -rf InvokeAI-Installer
# copy content
mkdir InvokeAI-Installer
for f in templates *.py *.txt *.reg; do
cp -r ${f} InvokeAI-Installer/
done
cp -pr ../environments-and-requirements templates readme.txt InvokeAI-Installer/
mkdir InvokeAI-Installer/templates/rootdir
cp -pr ../configs InvokeAI-Installer/templates/rootdir/
mkdir InvokeAI-Installer/templates/rootdir/{outputs,embeddings,models}
# Move the wheel
mv dist/*.whl InvokeAI-Installer/
# Install scripts
# Mac/Linux
perl -p -e "s/^INVOKEAI_VERSION=.*/INVOKEAI_VERSION=\"$VERSION\"/" install.sh.in > InvokeAI-Installer/install.sh
chmod a+rx InvokeAI-Installer/install.sh
zip -r InvokeAI-installer-$VERSION-linux.zip InvokeAI-Installer
zip -r InvokeAI-installer-$VERSION-mac.zip InvokeAI-Installer
# now do the windows installer
rm 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/
# this gets rid of the "-e ." at the end of the windows requirements file
# because it is easier to do it now than in the .bat install script
egrep -v '^-e .' InvokeAI-Installer/environments-and-requirements/requirements-win-colab-cuda.txt > InvokeAI-Installer/requirements.txt
cp InvokeAI-Installer/requirements.txt InvokeAI-Installer/environments-and-requirements/requirements-win-colab-cuda.txt
zip -r InvokeAI-installer-$VERSION-windows.zip InvokeAI-Installer
# Zip everything up
zip -r InvokeAI-installer-$VERSION.zip InvokeAI-Installer
# Updater
mkdir tmp
cp templates/update.sh.in tmp/update.sh
cp templates/update.bat.in tmp/update.bat
@ -66,9 +79,6 @@ cd ..
mv tmp/InvokeAI-updater-$VERSION.zip .
# clean up
rm -rf InvokeAI-Installer tmp
rm -rf InvokeAI-Installer tmp dist
exit 0

View File

@ -16,7 +16,6 @@ if "%1" == "use-cache" (
@rem The version in the next line is replaced by an up to date release number
@rem when create_installer.sh is run. Change the release number there.
set INVOKEAI_VERSION=latest
set INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/refs/tags/%INVOKEAI_VERSION%.zip
set INSTRUCTIONS=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/
set TROUBLESHOOTING=https://invoke-ai.github.io/InvokeAI/installation/INSTALL_AUTOMATED/#troubleshooting
set PYTHON_URL=https://www.python.org/downloads/windows/
@ -70,7 +69,6 @@ del /q .tmp1 .tmp2
call python main.py
@rem ------------------------ Subroutines ---------------
@rem routine to do comparison of semantic version numbers
@rem found at https://stackoverflow.com/questions/15807762/compare-version-numbers-in-batch-file

View File

@ -23,8 +23,8 @@ VERSION = "latest"
# Install the virtualenv into the runtime dir
FF_VENV_IN_RUNTIME = True
# Install the wheel from pypi
FF_USE_WHEEL = False
# Install the wheel packaged with the installer
FF_USE_LOCAL_WHEEL = True
class Installer:
@ -240,6 +240,7 @@ class InvokeAiInstance:
:type extra_index_url: str
"""
## this only applies to pypi installs; TODO actually use this
if self.version == "pre":
version = None
pre = "--pre"
@ -247,11 +248,16 @@ class InvokeAiInstance:
version = self.version
pre = None
if FF_USE_WHEEL:
src = f"invokeai=={version}" if version is not None else "invokeai"
else:
## TODO: only local wheel will be installed as of now; support for --version arg is TODO
if FF_USE_LOCAL_WHEEL:
src = str(next(Path.cwd().glob("InvokeAI-*.whl")))
elif version == "source":
# this makes an assumption about the location of the installer package in the source tree
src = Path(__file__).parents[1].expanduser().resolve()
else:
# will install from PyPp
src = f"invokeai=={version}" if version is not None else "invokeai"
import messages
from plumbum import FG, local

View File

@ -43,8 +43,8 @@ Launching the installer:
'./install.sh' (while keeping it inside the InvokeAI-Installer
folder).
The installer will create a directory named "invokeai" in the folder
of your choice. This directory contains everything you need to run
The installer will create a directory of your choice and install the
InvokeAI application within it. This directory contains everything you need to run
invokeai. Once InvokeAI is up and running, you may delete the
InvokeAI-Installer folder at your convenience.