(installer) fall back to attempted source install if wheel not found

if running `python3 installer/main.py` from the source distribution,
it would fail because it expected to find a wheel.

this PR tries to perform a source install by going one level up the directory
tree and checking for `pyproject.toml` and `ldm` directory entries to
confirm (to a degree) that this is an InvokeAI distribution
This commit is contained in:
Eugene Brodsky 2023-01-30 03:29:05 -05:00
parent 6b1dc34523
commit 11cb03f7de

View File

@ -250,7 +250,17 @@ class InvokeAiInstance:
## 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")))
# if no wheel, try to do a source install before giving up
try:
src = str(next(Path.cwd().glob("InvokeAI-*.whl")))
except StopIteration:
try:
src = Path(__file__).parents[1].expanduser().resolve()
# if the above directory contains one of these files, we'll do a source install
next(src.glob("pyproject.toml"))
next(src.glob("ldm"))
except StopIteration:
print("Unable to find a wheel or perform a source install. Giving up.")
elif version == "source":
# this makes an assumption about the location of the installer package in the source tree