From a4cc349f290f6c1eb5705470276d25e48d2da66e Mon Sep 17 00:00:00 2001
From: James Clarke <james@novora.ai>
Date: Mon, 24 Jun 2024 13:11:21 +0100
Subject: [PATCH 1/4] Updated pinned dependencues and enabled python 3.12

---
 pyproject.toml | 59 +++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index fcc0aff60cb..2d92c485db0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
 [project]
 name = "InvokeAI"
 description = "An implementation of Stable Diffusion which provides various new features and options to aid the image generation process"
-requires-python = ">=3.10, <3.12"
+requires-python = ">=3.10, <3.13"
 readme = { content-type = "text/markdown", file = "README.md" }
 keywords = ["stable-diffusion", "AI"]
 dynamic = ["version"]
@@ -31,49 +31,48 @@ classifiers = [
   'Topic :: Scientific/Engineering :: Artificial Intelligence',
   'Topic :: Scientific/Engineering :: Image Processing',
 ]
+
 dependencies = [
   # Core generation dependencies, pinned for reproducible builds.
-  "accelerate==0.30.1",
-  "clip_anytorch==2.6.0",       # replacing "clip @ https://github.com/openai/CLIP/archive/eaa22acb90a5876642d0507623e859909230a52d.zip",
+  "accelerate==0.31.0",
+  "clip_anytorch==2.6.0",
   "compel==2.0.2",
   "controlnet-aux==0.0.7",
-  "diffusers[torch]==0.27.2",
-  "invisible-watermark==0.2.0", # needed to install SDXL base and refiner using their repo_ids
-  "mediapipe==0.10.7",          # needed for "mediapipeface" controlnet model
-  "numpy==1.26.4",              # >1.24.0 is needed to use the 'strict' argument to np.testing.assert_array_equal()
-  "onnx==1.15.0",
-  "onnxruntime==1.16.3",
-  "opencv-python==4.9.0.80",
-  "pytorch-lightning==2.1.3",
+  "diffusers[torch]==0.29.1",
+  "invisible-watermark==0.2.0",
+  "mediapipe==0.10.13",
+  "numpy==1.26.4",
+  "onnx==1.16.1",
+  "onnxruntime==1.18.0",
+  "opencv-python==4.10.0.84",
+  "pytorch-lightning==2.3.0",
   "safetensors==0.4.3",
-  "timm==0.6.13",               # needed to override timm latest in controlnet_aux, see  https://github.com/isl-org/ZoeDepth/issues/26
-  "torch==2.2.2",
-  "torchmetrics==0.11.4",
+  "timm==0.6.13",
+  "torch==2.3.1",
+  "torchmetrics==1.4.0.post0",
   "torchsde==0.2.6",
-  "torchvision==0.17.2",
-  "transformers==4.41.1",
-
+  "torchvision==0.18.1",
+  "transformers==4.41.2",
   # Core application dependencies, pinned for reproducible builds.
-  "fastapi-events==0.11.0",
+  "fastapi-events==0.11.1",
   "fastapi==0.111.0",
-  "huggingface-hub==0.23.1",
-  "pydantic-settings==2.2.1",
-  "pydantic==2.7.2",
-  "python-socketio==5.11.1",
-  "uvicorn[standard]==0.28.0",
-
+  "huggingface-hub==0.23.4",
+  "pydantic-settings==2.3.3",
+  "pydantic==2.7.4",
+  "python-socketio==5.11.3",
+  "uvicorn[standard]==0.30.1",
   # Auxiliary dependencies, pinned only if necessary.
   "albumentations",
   "blake3",
   "click",
   "datasets",
   "Deprecated",
-  "dnspython~=2.4.0",
+  "dnspython~=2.4.2",
   "dynamicprompts",
   "easing-functions",
   "einops",
   "facexlib",
-  "matplotlib",       # needed for plotting of Penner easing functions
+  "matplotlib",
   "npyscreen",
   "omegaconf",
   "picklescan",
@@ -81,13 +80,13 @@ dependencies = [
   "prompt-toolkit",
   "pympler~=1.0.1",
   "pypatchmatch",
-  'pyperclip',
+  "pyperclip",
   "pyreadline3",
   "python-multipart",
   "requests~=2.28.2",
-  "rich~=13.3",
+  "rich~=13.7.1",
   "scikit-image~=0.21.0",
-  "semver~=3.0.1",
+  "semver~=3.0.2",
   "send2trash",
   "test-tube~=0.7.5",
   "windows-curses; sys_platform=='win32'",
@@ -96,7 +95,7 @@ dependencies = [
 [project.optional-dependencies]
 "xformers" = [
   # Core generation dependencies, pinned for reproducible builds.
-  "xformers==0.0.25post1; sys_platform!='darwin'",
+  "xformers==0.0.26post1; sys_platform!='darwin'",
   # Auxiliary dependencies, pinned only if necessary.
   "triton; sys_platform=='linux'",
 ]

From 3b3a0d18b62295a14a361c7912903468a4b0f925 Mon Sep 17 00:00:00 2001
From: James Clarke <james@novora.ai>
Date: Mon, 24 Jun 2024 14:59:58 +0100
Subject: [PATCH 2/4] Revert diffusers dep back to 0.27.2 due to API change

---
 pyproject.toml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 2d92c485db0..69fefa8ddd2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,6 @@
 [build-system]
-requires = ["setuptools~=65.5", "pip~=22.3", "wheel"]
+#requires = ["setuptools~=65.5", "pip~=22.3", "wheel"]
+requires = ["setuptools>=68.0", "wheel"]
 build-backend = "setuptools.build_meta"
 
 [project]
@@ -38,7 +39,7 @@ dependencies = [
   "clip_anytorch==2.6.0",
   "compel==2.0.2",
   "controlnet-aux==0.0.7",
-  "diffusers[torch]==0.29.1",
+  "diffusers[torch]==0.27.2",
   "invisible-watermark==0.2.0",
   "mediapipe==0.10.13",
   "numpy==1.26.4",

From 3defd5a96b64bfde7b0f60e00ec2bcb5bf87a6bb Mon Sep 17 00:00:00 2001
From: Lincoln Stein <lstein@gmail.com>
Date: Mon, 24 Jun 2024 20:53:29 -0400
Subject: [PATCH 3/4] updated installer to allow 3.12

---
 installer/install.bat.in   | 4 ++--
 installer/install.sh.in    | 4 ++--
 installer/lib/installer.py | 2 +-
 installer/readme.txt       | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/installer/install.bat.in b/installer/install.bat.in
index b06aa97c98b..70641383a20 100644
--- a/installer/install.bat.in
+++ b/installer/install.bat.in
@@ -27,7 +27,7 @@ set err_msg=An error has occurred and the script could not continue.
 echo This script will install InvokeAI and its dependencies.
 echo.
 echo BEFORE YOU START PLEASE MAKE SURE TO DO THE FOLLOWING
-echo 1. Install python 3.10 or 3.11. Python version 3.9 is no longer supported.
+echo 1. Install python 3.10-3.12. Python version 3.9 is no longer supported.
 echo 2. Double-click on the file WinLongPathsEnabled.reg in order to
 echo    enable long path support on your system.
 echo 3. Install the Visual C++ core libraries.
@@ -44,7 +44,7 @@ echo ***** Checking and Updating Python *****
 
 call python --version >.tmp1 2>.tmp2
 if %errorlevel% == 1 (
-   set err_msg=Please install Python 3.10-11. See %INSTRUCTIONS% for details.
+   set err_msg=Please install Python 3.10.12. See %INSTRUCTIONS% for details.
    goto err_exit
 )
 
diff --git a/installer/install.sh.in b/installer/install.sh.in
index 9cf41192bf1..54fbbd96788 100755
--- a/installer/install.sh.in
+++ b/installer/install.sh.in
@@ -9,9 +9,9 @@ cd $scriptdir
 function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
 
 MINIMUM_PYTHON_VERSION=3.10.0
-MAXIMUM_PYTHON_VERSION=3.11.100
+MAXIMUM_PYTHON_VERSION=3.12.100
 PYTHON=""
-for candidate in python3.11 python3.10 python3 python ; do
+for candidate in python3.12 python3.11 python3.10 python3 python ; do
     if ppath=`which $candidate`; then
         # when using `pyenv`, the executable for an inactive Python version will exist but will not be operational
         # we check that this found executable can actually run
diff --git a/installer/lib/installer.py b/installer/lib/installer.py
index 11823b413e0..942e5607074 100644
--- a/installer/lib/installer.py
+++ b/installer/lib/installer.py
@@ -15,7 +15,7 @@
 from tempfile import TemporaryDirectory
 from typing import Optional, Tuple
 
-SUPPORTED_PYTHON = ">=3.10.0,<=3.11.100"
+SUPPORTED_PYTHON = ">=3.10.0,<=3.12.100"
 INSTALLER_REQS = ["rich", "semver", "requests", "plumbum", "prompt-toolkit"]
 BOOTSTRAP_VENV_PREFIX = "invokeai-installer-tmp"
 DOCS_URL = "https://invoke-ai.github.io/InvokeAI/"
diff --git a/installer/readme.txt b/installer/readme.txt
index ef040c3913c..8229bbcc99c 100644
--- a/installer/readme.txt
+++ b/installer/readme.txt
@@ -14,14 +14,14 @@ Preparations:
      python --version
 
   If all is well, it will print "Python 3.X.X", where the version number
-  is at least 3.10.*, and not higher than 3.11.*.
+  is at least 3.10.*, and not higher than 3.12.*.
 
   If this works, check the version of the Python package manager, pip:
 
      pip --version
 
   You should get a message that indicates that the pip package
-  installer was derived from Python 3.10 or 3.11. For example:
+  installer was derived from Python 3.10, 3.11 or 3.12. For example:
   "pip 22.0.1 from /usr/bin/pip (python 3.10)"
 
 Long Paths on Windows:

From fcd00c7a595059b63db2dd27f5e8f74a372b2460 Mon Sep 17 00:00:00 2001
From: James David Clarke <james@novora.ai>
Date: Thu, 15 Aug 2024 09:00:46 +0100
Subject: [PATCH 4/4] Fix by adding back spandrel dependency

---
 pyproject.toml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pyproject.toml b/pyproject.toml
index 176493dcb36..9fb2a6e601d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -54,6 +54,7 @@ dependencies = [
   "torchsde==0.2.6",
   "torchvision==0.18.1",
   "transformers==4.41.2",
+  "spandrel",
   # Core application dependencies, pinned for reproducible builds.
   "fastapi-events==0.11.1",
   "fastapi==0.111.0",