From fc752a4e75810abc781a4b6d89e0392f57a9d887 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sat, 4 Feb 2023 16:14:29 -0500 Subject: [PATCH 1/2] move old .venv directory away during install - To ensure a clean environment, the installer will now detect whether a previous .venv exists in the install location, and move it to .venv-backup before creating a fresh .venv. - Any previous .venv-backup is deleted. - User is informed of process. --- installer/installer.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/installer/installer.py b/installer/installer.py index dfdc21730e..066b5bbf87 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -130,10 +130,24 @@ class Installer: else: venv_dir = self.dest / ".venv" + # if there is an existing venv directory, then we move it out of the way + # to create a clean install + if venv_dir.exists(): + backup_venv = self.dest / ".venv-backup" + print(f"Previous .venv directory detected. Renaming to {backup_venv}",end='') + if backup_venv.exists(): + print(f' and removing existing {backup_venv} directory',end='') + shutil.rmtree(backup_venv) + venv_dir.replace(backup_venv) + print('') + # Prefer to copy python executables # so that updates to system python don't break InvokeAI try: venv.create(venv_dir, with_pip=True) + # Because we moved away the previous .venv, the following code + # isn't strictly necessary, but keeping it here in case we decide + # it better to upgrade an existing venv rather than replace. # If installing over an existing environment previously created with symlinks, # the executables will fail to copy. Keep symlinks in that case except shutil.SameFileError: From eff7fb89d869f468214cb2214a8a6d363ea6504e Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 5 Feb 2023 13:39:46 -0500 Subject: [PATCH 2/2] installer will --force-reinstall torch --- installer/installer.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/installer/installer.py b/installer/installer.py index 066b5bbf87..6d33fe943d 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -130,24 +130,10 @@ class Installer: else: venv_dir = self.dest / ".venv" - # if there is an existing venv directory, then we move it out of the way - # to create a clean install - if venv_dir.exists(): - backup_venv = self.dest / ".venv-backup" - print(f"Previous .venv directory detected. Renaming to {backup_venv}",end='') - if backup_venv.exists(): - print(f' and removing existing {backup_venv} directory',end='') - shutil.rmtree(backup_venv) - venv_dir.replace(backup_venv) - print('') - # Prefer to copy python executables # so that updates to system python don't break InvokeAI try: venv.create(venv_dir, with_pip=True) - # Because we moved away the previous .venv, the following code - # isn't strictly necessary, but keeping it here in case we decide - # it better to upgrade an existing venv rather than replace. # If installing over an existing environment previously created with symlinks, # the executables will fail to copy. Keep symlinks in that case except shutil.SameFileError: @@ -263,6 +249,7 @@ class InvokeAiInstance: "--require-virtualenv", "torch", "torchvision", + "--force-reinstall", "--find-links" if find_links is not None else None, find_links, "--extra-index-url" if extra_index_url is not None else None, @@ -339,6 +326,7 @@ class InvokeAiInstance: Configure the InvokeAI runtime directory """ + # set sys.argv to a consistent state new_argv = [sys.argv[0]] for i in range(1,len(sys.argv)): el = sys.argv[i] @@ -353,15 +341,13 @@ class InvokeAiInstance: introduction() - from ldm.invoke.config import configure_invokeai + from ldm.invoke.config import invokeai_configure # NOTE: currently the config script does its own arg parsing! this means the command-line switches # from the installer will also automatically propagate down to the config script. # this may change in the future with config refactoring! - # set sys.argv to a consistent state - - configure_invokeai.main() + invokeai_configure.main() def install_user_scripts(self): """