Update utilities.py

This commit is contained in:
Saifeddine ALOUI 2024-03-11 14:15:07 +01:00 committed by GitHub
parent b0caa9804d
commit 89102b9c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,13 +38,14 @@ import git
import mimetypes
import subprocess
from conda.cli.python_api import run_command, Commands
def create_conda_env(env_name, python_version):
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_python_script_in_env(env_name, script_path, cwd=None):
from conda.cli.python_api import run_command, Commands
# Set the current working directory if provided, otherwise use the current directory
if cwd is None:
cwd = os.getcwd()
@ -53,6 +54,7 @@ def run_python_script_in_env(env_name, script_path, cwd=None):
run_command(Commands.RUN, "-n", env_name, "python", str(script_path), cwd=cwd)
def run_script_in_env(env_name, script_path, cwd=None):
from conda.cli.python_api import run_command, Commands
# Set the current working directory if provided, otherwise use the current directory
if cwd is None:
cwd = os.path.dirname(script_path)