From 3b43f3a5a1440b1c2d2d9043764bf795f042275a Mon Sep 17 00:00:00 2001 From: Eugene Brodsky Date: Fri, 3 Feb 2023 00:36:26 -0500 Subject: [PATCH] (installer) fix failure to create venv over an existing venv if reinstalling over an existing installation where the .venv was created with symlinks to system python instead of copies of the python executable, the installer would raise a SameFileError, because it would attempt to copy Python over itself. This fixes the issue. --- installer/installer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/installer/installer.py b/installer/installer.py index 888ed42b8b..e9d2cc392c 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -129,7 +129,14 @@ class Installer: else: venv_dir = self.dest / ".venv" - venv.create(venv_dir, with_pip=True) + # Prefer to copy python executables + # so that updates to system python don't break InvokeAI + try: + venv.create(venv_dir, with_pip=True) + # If installing over an existing environment previously created with symlinks, + # the executables will fail to copy. Keep symlinks in that case + except shutil.SameFileError: + venv.create(venv_dir, with_pip=True, symlinks=True) # upgrade pip in Python 3.9 environments if int(platform.python_version_tuple()[1]) == 9: