(installer) Windows fixes

This commit is contained in:
Eugene Brodsky 2023-01-09 00:13:01 -05:00
parent 2296f5449e
commit d3962ab7b5
2 changed files with 16 additions and 11 deletions

View File

@ -2,6 +2,8 @@
InvokeAI installer script InvokeAI installer script
""" """
import os
import platform
import subprocess import subprocess
import sys import sys
import venv import venv
@ -10,15 +12,16 @@ from tempfile import TemporaryDirectory
SUPPORTED_PYTHON = ">=3.9.0,<3.11" SUPPORTED_PYTHON = ">=3.9.0,<3.11"
INSTALLER_REQS = ["rich", "semver"] INSTALLER_REQS = ["rich", "semver"]
PLATFORM = sys.platform
OS = platform.uname().system
ARCH = platform.uname().machine
VERSION = "latest"
### Feature flags ### Feature flags
# Place the virtualenv inside the runtime dir # Install the virtualenv into the runtime dir
# (default for 2.2.5) == True
VENV_IN_RUNTIME = True VENV_IN_RUNTIME = True
# Install the wheel from pypi # Install the wheel from pypi
# (default for 2.2.5) == False
USE_WHEEL = False USE_WHEEL = False
@ -46,7 +49,7 @@ class Installer:
pass pass
def inst_venv(self) -> TemporaryDirectory: def mktemp_venv(self) -> TemporaryDirectory:
""" """
Creates a temporary virtual environment for the installer itself Creates a temporary virtual environment for the installer itself
@ -56,7 +59,8 @@ class Installer:
venv_dir = TemporaryDirectory(prefix="invokeai-installer-") venv_dir = TemporaryDirectory(prefix="invokeai-installer-")
venv.create(venv_dir.name, with_pip=True) venv.create(venv_dir.name, with_pip=True)
sys.path.append(f"{venv_dir.name}/lib/python{sys.version_info.major}.{sys.version_info.minor}/site-packages") lib = "Lib" if OS == "Windows" else f"lib/python{sys.version_info.major}.{sys.version_info.minor}"
sys.path.append(str(Path(venv_dir.name, lib, "site-packages").absolute()))
self.venv_dir = venv_dir self.venv_dir = venv_dir
return venv_dir return venv_dir
@ -69,10 +73,11 @@ class Installer:
:rtype: TemporaryDirectory :rtype: TemporaryDirectory
""" """
print("Initializing the installer, please wait...") print("Initializing the installer. This may take a minute - please wait...")
venv_dir = self.inst_venv() venv_dir = self.mktemp_venv()
pip = str(Path(venv_dir.name).absolute() / "bin/pip") pip = "Scripts\pip.exe" if OS == "Windows" else "bin/pip"
pip = str(Path(venv_dir.name).absolute() / pip)
cmd = [pip, "install", "--require-virtualenv"] cmd = [pip, "install", "--require-virtualenv"]
cmd.extend(self.reqs) cmd.extend(self.reqs)

View File

@ -23,7 +23,7 @@ def welcome():
console.rule() console.rule()
print( print(
Panel( Panel(
title="[bold wheat1]Welcome to the InvokeAI Installer!", title="[bold wheat1]Welcome to the InvokeAI Installer",
renderable=Text( renderable=Text(
"Some of the installation steps take a long time to run. Please be patient. If the script appears to hang for more than 10 minutes, please interrupt with control-C and retry.", "Some of the installation steps take a long time to run. Please be patient. If the script appears to hang for more than 10 minutes, please interrupt with control-C and retry.",
justify="center", justify="center",
@ -33,7 +33,7 @@ def welcome():
expand=False, expand=False,
padding=(1, 2), padding=(1, 2),
style=Style(bgcolor="grey23", color="orange1"), style=Style(bgcolor="grey23", color="orange1"),
subtitle=f"[wheat1] Installing for [bold]{OS}-{ARCH}", subtitle=f"[bold grey39]{OS}-{ARCH}",
) )
) )
console.line() console.line()