diff --git a/apps/stable_diffusion/web/index.py b/apps/stable_diffusion/web/index.py index 258a92749a..5927775af6 100644 --- a/apps/stable_diffusion/web/index.py +++ b/apps/stable_diffusion/web/index.py @@ -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 @@ -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, diff --git a/apps/stable_diffusion/web/utils/updater.py b/apps/stable_diffusion/web/utils/updater.py new file mode 100644 index 0000000000..7531ea05ec --- /dev/null +++ b/apps/stable_diffusion/web/utils/updater.py @@ -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)