Skip to content

Commit 6796147

Browse files
committed
add version check
1 parent e568ea5 commit 6796147

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

webui.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,22 @@ def warning_if_invalid_install_dir():
5959
6060
This check should be removed when it's no longer applicable.
6161
"""
62+
from packaging.version import parse
6263
from pathlib import Path
64+
import gradio
6365

64-
def abspath(path):
65-
"""modified from Gradio 3.41.2 gradio.utils.abspath()"""
66-
if path.is_absolute():
67-
return path
68-
is_symlink = path.is_symlink() or any(parent.is_symlink() for parent in path.parents)
69-
if is_symlink or path == path.resolve():
70-
return Path.cwd() / path
71-
else:
72-
return path.resolve()
73-
webui_root = Path(__file__).parent
74-
if any(part.startswith(".") for part in abspath(webui_root).parts):
75-
print(f'''{"!"*25} Warning {"!"*25}
66+
if parse('3.32.0') <= parse(gradio.__version__) < parse('4'):
67+
68+
def abspath(path):
69+
"""modified from Gradio 3.41.2 gradio.utils.abspath()"""
70+
if path.is_absolute():
71+
return path
72+
is_symlink = path.is_symlink() or any(parent.is_symlink() for parent in path.parents)
73+
return Path.cwd() / path if (is_symlink or path == path.resolve()) else path.resolve()
74+
75+
webui_root = Path(__file__).parent
76+
if any(part.startswith(".") for part in abspath(webui_root).parts):
77+
print(f'''{"!"*25} Warning {"!"*25}
7678
WebUI is installed in a directory that has a leading dot (.) in one of its parent directories.
7779
This will prevent WebUI from functioning properly.
7880
Please move the installation to a different directory.

0 commit comments

Comments
 (0)