alternative version of _find_root()

This commit is contained in:
Lincoln Stein 2023-07-08 08:38:45 -04:00
parent b11d5970f6
commit c2b0f83be3

View File

@ -325,11 +325,11 @@ class InvokeAISettings(BaseSettings):
help=field.field_info.description, help=field.field_info.description,
) )
def _find_root()->Path: def _find_root()->Path:
venv = os.environ.get("VIRTUAL_ENV") venv = Path(os.environ.get("VIRTUAL_ENV") or ".")
if os.environ.get("INVOKEAI_ROOT"): if os.environ.get("INVOKEAI_ROOT"):
root = Path(os.environ.get("INVOKEAI_ROOT")).resolve() root = Path(os.environ.get("INVOKEAI_ROOT")).resolve()
elif any([Path(venv, '..', x).exists() for x in [INIT_FILE, LEGACY_INIT_FILE, MODEL_CORE]]): elif any([(venv.parent/x).exists() for x in [INIT_FILE, LEGACY_INIT_FILE, MODEL_CORE]]):
root = Path(venv, "..").resolve() root = (venv.parent).resolve()
else: else:
root = Path("~/invokeai").expanduser().resolve() root = Path("~/invokeai").expanduser().resolve()
return root return root