mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-06-19 08:17:49 +02:00
Fix for conda accidental jailbreak when using WebUI
This commit is contained in:
parent
fd76a160ac
commit
e57599c01e
@ -81,34 +81,43 @@ def install_backend():
|
||||
# install python 3.10 and git in the conda env
|
||||
run([conda, "install", "-y", "--prefix", SYSTEM_DIR, "-c", "conda-forge", "python=3.10", "git"], cwd=ROOT_DIR)
|
||||
|
||||
env = dict(os.environ)
|
||||
env.update(get_env())
|
||||
|
||||
# print info
|
||||
run_in_conda(["git", "--version"], cwd=ROOT_DIR)
|
||||
run_in_conda(["python", "--version"], cwd=ROOT_DIR)
|
||||
run_in_conda(["git", "--version"], cwd=ROOT_DIR, env=env)
|
||||
run_in_conda(["python", "--version"], cwd=ROOT_DIR, env=env)
|
||||
|
||||
# clone webui
|
||||
run_in_conda(["git", "clone", WEBUI_REPO, WEBUI_DIR], cwd=ROOT_DIR)
|
||||
run_in_conda(["git", "clone", WEBUI_REPO, WEBUI_DIR], cwd=ROOT_DIR, env=env)
|
||||
|
||||
# install cpu-only torch if the PC doesn't have a graphics card (for Windows and Linux).
|
||||
# this avoids WebUI installing a CUDA version and trying to activate it
|
||||
if OS_NAME in ("Windows", "Linux") and not has_discrete_graphics_card():
|
||||
run_in_conda(["python", "-m", "pip", "install", "torch", "torchvision"], cwd=WEBUI_DIR)
|
||||
run_in_conda(["python", "-m", "pip", "install", "torch", "torchvision"], cwd=WEBUI_DIR, env=env)
|
||||
|
||||
|
||||
def start_backend():
|
||||
config = getConfig()
|
||||
backend_config = config.get("backend_config", {})
|
||||
|
||||
env = dict(os.environ)
|
||||
env.update(get_env())
|
||||
|
||||
if not os.path.exists(BACKEND_DIR):
|
||||
install_backend()
|
||||
|
||||
was_still_installing = not is_installed()
|
||||
|
||||
if backend_config.get("auto_update", True):
|
||||
run_in_conda(["git", "add", "-A", "."], cwd=WEBUI_DIR)
|
||||
run_in_conda(["git", "stash"], cwd=WEBUI_DIR)
|
||||
run_in_conda(["git", "reset", "--hard"], cwd=WEBUI_DIR)
|
||||
run_in_conda(["git", "fetch"], cwd=WEBUI_DIR)
|
||||
run_in_conda(["git", "-c", "advice.detachedHead=false", "checkout", WEBUI_COMMIT], cwd=WEBUI_DIR)
|
||||
run_in_conda(["git", "add", "-A", "."], cwd=WEBUI_DIR, env=env)
|
||||
run_in_conda(["git", "stash"], cwd=WEBUI_DIR, env=env)
|
||||
run_in_conda(["git", "reset", "--hard"], cwd=WEBUI_DIR, env=env)
|
||||
run_in_conda(["git", "fetch"], cwd=WEBUI_DIR, env=env)
|
||||
run_in_conda(["git", "-c", "advice.detachedHead=false", "checkout", WEBUI_COMMIT], cwd=WEBUI_DIR, env=env)
|
||||
|
||||
# workaround for the installations that broke out of conda and used ED's python 3.8 instead of WebUI conda's Py 3.10
|
||||
run_in_conda(["python", "-m", "pip", "install", "-q", "--upgrade", "urllib3==2.2.3"], cwd=WEBUI_DIR, env=env)
|
||||
|
||||
# hack to prevent webui-macos-env.sh from overwriting the COMMANDLINE_ARGS env variable
|
||||
mac_webui_file = os.path.join(WEBUI_DIR, "webui-macos-env.sh")
|
||||
@ -118,9 +127,6 @@ def start_backend():
|
||||
impl.WEBUI_HOST = backend_config.get("host", "localhost")
|
||||
impl.WEBUI_PORT = backend_config.get("port", "7860")
|
||||
|
||||
env = dict(os.environ)
|
||||
env.update(get_env())
|
||||
|
||||
def restart_if_webui_dies_after_starting():
|
||||
has_started = False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user