From 4ab2436f90e089028f9001e3eca9c66489c967f0 Mon Sep 17 00:00:00 2001 From: SunK SugaR <1281098609@qq.com> Date: Tue, 3 Dec 2024 12:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bugfix:=20env=20won't=20reinstal?= =?UTF-8?q?l=20if=20it=20doesn't=20exist.=20(#47)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: SunKSugaR --- start_cli.py | 1 + start_webui.py | 1 + utils/install_utils.py | 18 +++++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/start_cli.py b/start_cli.py index b8ca7668..1c066523 100644 --- a/start_cli.py +++ b/start_cli.py @@ -23,6 +23,7 @@ def main(): install_mgr.setup() # Activate environment and run main.py + install_mgr.check_environment() if platform.system().lower() == "windows": activate_cmd = f"call {install_mgr.activate_script} {install_mgr.env_name}" else: diff --git a/start_webui.py b/start_webui.py index 2174cee0..cddb69a3 100644 --- a/start_webui.py +++ b/start_webui.py @@ -23,6 +23,7 @@ def main(): install_mgr.setup() # Activate environment and run server + install_mgr.check_environment() if platform.system().lower() == "windows": activate_cmd = f"call {install_mgr.activate_script} {install_mgr.env_name}" else: diff --git a/utils/install_utils.py b/utils/install_utils.py index 36a6a450..ba0d0179 100644 --- a/utils/install_utils.py +++ b/utils/install_utils.py @@ -115,13 +115,8 @@ def install_pip_dependencies(self): else: subprocess.run(["bash", "-c", pip_install_cmd], check=True) - def setup(self): - """Run complete setup process""" - if not self.conda_dir.exists(): - installer = self.download_miniconda() - self.install_miniconda(installer) - - # Create environment if it doesn't exist + def check_environment(self): + """Check if 'open-llm-vtuber' environment exists and install if not""" result = subprocess.run( [str(self.conda_executable), "env", "list"], capture_output=True, @@ -132,3 +127,12 @@ def setup(self): self.create_environment() self.install_conda_dependencies() self.install_pip_dependencies() + + def setup(self): + """Run complete setup process""" + if not self.conda_dir.exists(): + installer = self.download_miniconda() + self.install_miniconda(installer) + + # Create environment if it doesn't exist + self.check_environment() \ No newline at end of file