From 67961472a51353ddcfd0630a6f2f3ade7e3dbcd4 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:44:14 +0900 Subject: [PATCH] add version check --- webui.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/webui.py b/webui.py index b1e2faa48..421e3b833 100644 --- a/webui.py +++ b/webui.py @@ -59,20 +59,22 @@ def warning_if_invalid_install_dir(): This check should be removed when it's no longer applicable. """ + from packaging.version import parse from pathlib import Path + import gradio - def abspath(path): - """modified from Gradio 3.41.2 gradio.utils.abspath()""" - if path.is_absolute(): - return path - is_symlink = path.is_symlink() or any(parent.is_symlink() for parent in path.parents) - if is_symlink or path == path.resolve(): - return Path.cwd() / path - else: - return path.resolve() - webui_root = Path(__file__).parent - if any(part.startswith(".") for part in abspath(webui_root).parts): - print(f'''{"!"*25} Warning {"!"*25} + if parse('3.32.0') <= parse(gradio.__version__) < parse('4'): + + def abspath(path): + """modified from Gradio 3.41.2 gradio.utils.abspath()""" + if path.is_absolute(): + return path + is_symlink = path.is_symlink() or any(parent.is_symlink() for parent in path.parents) + return Path.cwd() / path if (is_symlink or path == path.resolve()) else path.resolve() + + webui_root = Path(__file__).parent + if any(part.startswith(".") for part in abspath(webui_root).parts): + print(f'''{"!"*25} Warning {"!"*25} WebUI is installed in a directory that has a leading dot (.) in one of its parent directories. This will prevent WebUI from functioning properly. Please move the installation to a different directory.