Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Autoupdate Mechanism #1708

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/stable_diffusion/web/index.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from multiprocessing import Process, freeze_support
import os
import sys
import subprocess
from apps.stable_diffusion.web.utils import install_updates

if sys.platform == "darwin":
# import before IREE to avoid torch-MLIR library issues
Expand Down Expand Up @@ -43,6 +45,10 @@ def launch_app(address):
if __name__ == "__main__":
# required to do multiprocessing in a pyinstaller freeze
freeze_support()

# install updates if running in windows
install_updates()

if args.api or "api" in args.ui.split(","):
from apps.stable_diffusion.web.ui import (
txt2img_api,
Expand Down
25 changes: 25 additions & 0 deletions apps/stable_diffusion/web/utils/updater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file contains auto update triggers for all installable distributions
import os
import sys
import subprocess


# In Windows MSI ONLY
def install_updates():
"""Installs update from latest release on GitHub if currently running on Windows MSI and an update exists"""

# Ensures that code is running in a pyinstaller bundle on windows
if sys.platform != "win32" or not getattr(sys, "frozen", False):
return

# Gets path to updater.exe
application_path = os.path.dirname(sys.executable)
application_path, _ = os.path.split(application_path)
application_path = os.path.join(application_path, "updater.exe")

# If updater exe does not exist, do nothing
if not os.path.isfile(application_path):
return

# run updater.exe
subprocess.run(application_path)