Skip to content

Commit d0fa131

Browse files
authored
(feat) updater installs from PyPi instead of GitHub releases (#5316)
## What type of PR is this? (check all applicable) - [ ] Refactor - [ ] Feature - [ ] Bug Fix - [X] Optimization - [ ] Documentation Update - [ ] Community Node Submission ## Have you discussed this change with the InvokeAI team? - [X] Yes - [ ] No, because: ## Have you updated all relevant documentation? - [ ] Yes - [X] No ## Description Updater script pulls from PyPI instead of GitHub releases (this is why the RC packages are having issues when updating through the launcher script) ## Related Tickets & Documents <!-- For pull requests that relate or close an issue, please include them below. For example having the text: "closes #1234" would connect the current pull request to issue 1234. And when we merge the pull request, Github will automatically close the issue. --> - Related Issue # - Closes # ## QA Instructions, Screenshots, Recordings <!-- Please provide steps on how to test changes, any hardware or software specifications as well as any other pertinent information. --> ## Merge Plan <!-- A merge plan describes how this PR should be handled after it is approved. Example merge plans: - "This PR can be merged when approved" - "This must be squash-merged when approved" - "DO NOT MERGE - I will rebase and tidy commits before merging" - "#dev-chat on discord needs to be advised of this change when it is merged" A merge plan is particularly important for large PRs or PRs that touch the database in any way. --> ## Added/updated tests? - [ ] Yes - [X] No : _please replace this line with details on why tests have not been included_ ## [optional] Are there any post deployment tasks we need to perform?
2 parents 42be78d + 2f43843 commit d0fa131

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

invokeai/frontend/install/invokeai_update.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55
import os
66
import platform
7+
from distutils.version import LooseVersion
78

89
import pkg_resources
910
import psutil
@@ -31,10 +32,6 @@
3132
console = Console(style=Style(color="grey74", bgcolor="grey19"))
3233

3334

34-
def get_versions() -> dict:
35-
return requests.get(url=INVOKE_AI_REL).json()
36-
37-
3835
def invokeai_is_running() -> bool:
3936
for p in psutil.process_iter():
4037
try:
@@ -50,6 +47,20 @@ def invokeai_is_running() -> bool:
5047
return False
5148

5249

50+
def get_pypi_versions():
51+
url = "https://pypi.org/pypi/invokeai/json"
52+
try:
53+
data = requests.get(url).json()
54+
except Exception:
55+
raise Exception("Unable to fetch version information from PyPi")
56+
57+
versions = list(data["releases"].keys())
58+
versions.sort(key=LooseVersion, reverse=True)
59+
latest_version = [v for v in versions if "rc" not in v][0]
60+
latest_release_candidate = [v for v in versions if "rc" in v][0]
61+
return latest_version, latest_release_candidate, versions
62+
63+
5364
def welcome(latest_release: str, latest_prerelease: str):
5465
@group()
5566
def text():
@@ -63,8 +74,7 @@ def text():
6374
yield "[bold yellow]Options:"
6475
yield f"""[1] Update to the latest [bold]official release[/bold] ([italic]{latest_release}[/italic])
6576
[2] Update to the latest [bold]pre-release[/bold] (may be buggy; caveat emptor!) ([italic]{latest_prerelease}[/italic])
66-
[3] Manually enter the [bold]tag name[/bold] for the version you wish to update to
67-
[4] Manually enter the [bold]branch name[/bold] for the version you wish to update to"""
77+
[3] Manually enter the [bold]version[/bold] you wish to update to"""
6878

6979
console.rule()
7080
print(
@@ -92,44 +102,35 @@ def get_extras():
92102

93103

94104
def main():
95-
versions = get_versions()
96-
released_versions = [x for x in versions if not (x["draft"] or x["prerelease"])]
97-
prerelease_versions = [x for x in versions if not x["draft"] and x["prerelease"]]
98-
latest_release = released_versions[0]["tag_name"] if len(released_versions) else None
99-
latest_prerelease = prerelease_versions[0]["tag_name"] if len(prerelease_versions) else None
100-
101105
if invokeai_is_running():
102106
print(":exclamation: [bold red]Please terminate all running instances of InvokeAI before updating.[/red bold]")
103107
input("Press any key to continue...")
104108
return
105109

110+
latest_release, latest_prerelease, versions = get_pypi_versions()
111+
106112
welcome(latest_release, latest_prerelease)
107113

108-
tag = None
109-
branch = None
110-
release = None
111-
choice = Prompt.ask("Choice:", choices=["1", "2", "3", "4"], default="1")
114+
release = latest_release
115+
choice = Prompt.ask("Choice:", choices=["1", "2", "3"], default="1")
112116

113117
if choice == "1":
114118
release = latest_release
115119
elif choice == "2":
116120
release = latest_prerelease
117121
elif choice == "3":
118-
while not tag:
119-
tag = Prompt.ask("Enter an InvokeAI tag name")
120-
elif choice == "4":
121-
while not branch:
122-
branch = Prompt.ask("Enter an InvokeAI branch name")
122+
while True:
123+
release = Prompt.ask("Enter an InvokeAI version")
124+
release.strip()
125+
if release in versions:
126+
break
127+
print(f":exclamation: [bold red]'{release}' is not a recognized InvokeAI release.[/red bold]")
123128

124129
extras = get_extras()
125130

126-
print(f":crossed_fingers: Upgrading to [yellow]{tag or release or branch}[/yellow]")
127-
if release:
128-
cmd = f'pip install "invokeai{extras} @ {INVOKE_AI_SRC}/{release}.zip" --use-pep517 --upgrade'
129-
elif tag:
130-
cmd = f'pip install "invokeai{extras} @ {INVOKE_AI_TAG}/{tag}.zip" --use-pep517 --upgrade'
131-
else:
132-
cmd = f'pip install "invokeai{extras} @ {INVOKE_AI_BRANCH}/{branch}.zip" --use-pep517 --upgrade'
131+
print(f":crossed_fingers: Upgrading to [yellow]{release}[/yellow]")
132+
cmd = f'pip install "invokeai{extras}=={release}" --use-pep517 --upgrade'
133+
133134
print("")
134135
print("")
135136
if os.system(cmd) == 0:

0 commit comments

Comments
 (0)