got rid of conda

This commit is contained in:
Saifeddine ALOUI 2024-10-08 23:33:01 +02:00
parent 246f2e3df8
commit 269c640dbc
3 changed files with 3 additions and 63 deletions

View File

@ -8,7 +8,7 @@ License: Apache 2.0
""" """
from lollms.utilities import PackageManager from lollms.utilities import PackageManager
from lollms.com import LoLLMsCom from lollms.com import LoLLMsCom
from lollms.utilities import trace_exception, run_async, install_conda_package from lollms.utilities import trace_exception, run_async
from lollms.types import MSG_OPERATION_TYPE, SENDER_TYPES from lollms.types import MSG_OPERATION_TYPE, SENDER_TYPES
from lollms.client_session import Session from lollms.client_session import Session
from ascii_colors import ASCIIColors from ascii_colors import ASCIIColors

View File

@ -5,9 +5,6 @@
from pathlib import Path from pathlib import Path
from lollms.app import LollmsApplication from lollms.app import LollmsApplication
from lollms.paths import LollmsPaths
from lollms.config import TypedConfig, ConfigTemplate, BaseConfig
from lollms.utilities import PackageManager, install_conda_package
from lollms.stt import LollmsSTT from lollms.stt import LollmsSTT
from dataclasses import dataclass from dataclasses import dataclass
from PIL import Image, PngImagePlugin from PIL import Image, PngImagePlugin
@ -22,13 +19,13 @@ try:
if not pm.is_installed("openai-whisper"): if not pm.is_installed("openai-whisper"):
pm.install("openai-whisper") pm.install("openai-whisper")
try: try:
install_conda_package("conda-forge::ffmpeg") pass#install_conda_package("conda-forge::ffmpeg")
except Exception as ex: except Exception as ex:
trace_exception(ex) trace_exception(ex)
ASCIIColors.red("Couldn't install ffmpeg") ASCIIColors.red("Couldn't install ffmpeg")
except: except:
try: try:
install_conda_package("conda-forge::ffmpeg") pass#install_conda_package("conda-forge::ffmpeg")
except Exception as ex: except Exception as ex:
trace_exception(ex) trace_exception(ex)
ASCIIColors.red("Couldn't install ffmpeg") ASCIIColors.red("Couldn't install ffmpeg")

View File

@ -40,63 +40,6 @@ import subprocess
from functools import partial from functools import partial
def install_conda_utility():
import platform
if platform.system()=="Windows":
conda_path = Path(sys.executable).parent.parent/"miniconda3"/"condabin"/"conda"
else:
conda_path = Path(sys.executable).parent.parent.parent/"miniconda3"/"bin"/"conda"
ASCIIColors.red("Conda path:")
ASCIIColors.yellow(conda_path)
process = subprocess.Popen(f'{conda_path} install conda -y', shell=True)
# Wait for the process to finish
process.wait()
#from conda.cli.python_api import run_command, Commands
# Create a new Conda environment with the specified Python version
#run_command(Commands.CREATE, "-n", env_name, f"python={python_version}")
def install_conda_package(package_name):
try:
import platform
if platform.system()=="Windows":
conda_path = Path(sys.executable).parent.parent/"miniconda3"/"condabin"/"conda"
else:
conda_path = Path(sys.executable).parent.parent.parent/"miniconda3"/"bin"/"conda"
ASCIIColors.red("Conda path:")
ASCIIColors.yellow(conda_path)
process = subprocess.Popen(f'{conda_path} install {package_name} -y', shell=True)
# Wait for the process to finish
process.wait()
#from conda.cli.python_api import run_command, Commands
# Create a new Conda environment with the specified Python version
#run_command(Commands.CREATE, "-n", env_name, f"python={python_version}")
return True
except Exception as ex:
trace_exception(ex)
return False
def create_conda_env(env_name, python_version):
from lollms.security import sanitize_shell_code
env_name = sanitize_shell_code(env_name)
python_version = sanitize_shell_code(python_version)
# Activate the Conda environment
import platform
if platform.system()=="Windows":
conda_path = Path(sys.executable).parent.parent/"miniconda3"/"condabin"/"conda"
else:
conda_path = Path(sys.executable).parent.parent.parent/"miniconda3"/"bin"/"conda"
ASCIIColors.red("Conda path: ",flush=True, end="")
ASCIIColors.yellow(conda_path)
process = subprocess.Popen(f'{conda_path} create --name {env_name} python={python_version} -y', shell=True)
# Wait for the process to finish
process.wait()
#from conda.cli.python_api import run_command, Commands
# Create a new Conda environment with the specified Python version
#run_command(Commands.CREATE, "-n", env_name, f"python={python_version}")
def run_pip_in_env(env_name, pip_args, cwd=None): def run_pip_in_env(env_name, pip_args, cwd=None):
import platform import platform
# Set the current working directory if provided, otherwise use the current directory # Set the current working directory if provided, otherwise use the current directory