Skip to content

Commit b20cd35

Browse files
Merge pull request AUTOMATIC1111#13210 from AUTOMATIC1111/fetch-version-info-when-webui_dir-is-not-work_dir-
fix issues when webui_dir is not work_dir
2 parents 3a4290f + 5b761b4 commit b20cd35

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

modules/launch_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ def check_python_version():
6464
@lru_cache()
6565
def commit_hash():
6666
try:
67-
return subprocess.check_output([git, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip()
67+
return subprocess.check_output([git, "-C", script_path, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip()
6868
except Exception:
6969
return "<none>"
7070

7171

7272
@lru_cache()
7373
def git_tag():
7474
try:
75-
return subprocess.check_output([git, "describe", "--tags"], shell=False, encoding='utf8').strip()
75+
return subprocess.check_output([git, "-C", script_path, "describe", "--tags"], shell=False, encoding='utf8').strip()
7676
except Exception:
7777
try:
7878

modules/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import sys
3-
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir # noqa: F401
3+
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
44

55
import modules.safe # noqa: F401
66

modules/paths_internal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
99
sys.argv += shlex.split(commandline_args)
1010

11+
cwd = os.getcwd()
1112
modules_path = os.path.dirname(os.path.realpath(__file__))
1213
script_path = os.path.dirname(modules_path)
1314

modules/ui_gradio_extensions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import gradio as gr
33

44
from modules import localization, shared, scripts
5-
from modules.paths import script_path, data_path
5+
from modules.paths import script_path, data_path, cwd
66

77

88
def webpath(fn):
9-
if fn.startswith(script_path):
10-
web_path = os.path.relpath(fn, script_path).replace('\\', '/')
9+
if fn.startswith(cwd):
10+
web_path = os.path.relpath(fn, cwd)
1111
else:
1212
web_path = os.path.abspath(fn)
1313

0 commit comments

Comments
 (0)