Commit b20cd352 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #13210 from AUTOMATIC1111/fetch-version-info-when-webui_dir-is-not-work_dir-

fix issues when webui_dir is not work_dir
parents 3a4290f8 5b761b49
...@@ -64,7 +64,7 @@ Use --skip-python-version-check to suppress this warning. ...@@ -64,7 +64,7 @@ Use --skip-python-version-check to suppress this warning.
@lru_cache() @lru_cache()
def commit_hash(): def commit_hash():
try: try:
return subprocess.check_output([git, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip() return subprocess.check_output([git, "-C", script_path, "rev-parse", "HEAD"], shell=False, encoding='utf8').strip()
except Exception: except Exception:
return "<none>" return "<none>"
...@@ -72,7 +72,7 @@ def commit_hash(): ...@@ -72,7 +72,7 @@ def commit_hash():
@lru_cache() @lru_cache()
def git_tag(): def git_tag():
try: try:
return subprocess.check_output([git, "describe", "--tags"], shell=False, encoding='utf8').strip() return subprocess.check_output([git, "-C", script_path, "describe", "--tags"], shell=False, encoding='utf8').strip()
except Exception: except Exception:
try: try:
......
import os import os
import sys import sys
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir # noqa: F401 from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
import modules.safe # noqa: F401 import modules.safe # noqa: F401
......
...@@ -8,6 +8,7 @@ import shlex ...@@ -8,6 +8,7 @@ import shlex
commandline_args = os.environ.get('COMMANDLINE_ARGS', "") commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
sys.argv += shlex.split(commandline_args) sys.argv += shlex.split(commandline_args)
cwd = os.getcwd()
modules_path = os.path.dirname(os.path.realpath(__file__)) modules_path = os.path.dirname(os.path.realpath(__file__))
script_path = os.path.dirname(modules_path) script_path = os.path.dirname(modules_path)
......
...@@ -2,12 +2,12 @@ import os ...@@ -2,12 +2,12 @@ import os
import gradio as gr import gradio as gr
from modules import localization, shared, scripts from modules import localization, shared, scripts
from modules.paths import script_path, data_path from modules.paths import script_path, data_path, cwd
def webpath(fn): def webpath(fn):
if fn.startswith(script_path): if fn.startswith(cwd):
web_path = os.path.relpath(fn, script_path).replace('\\', '/') web_path = os.path.relpath(fn, cwd)
else: else:
web_path = os.path.abspath(fn) web_path = os.path.abspath(fn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment