fix conda package management using conda executable instead of python -m conda
This commit is contained in:
@@ -90,9 +90,14 @@ def get_installed_packages() -> Set[str]:
|
|||||||
Returns:
|
Returns:
|
||||||
Set of package names
|
Set of package names
|
||||||
"""
|
"""
|
||||||
|
conda_exe = get_conda_executable()
|
||||||
|
if not conda_exe:
|
||||||
|
log.error("Failed to list conda packages: conda executable not found")
|
||||||
|
return set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[sys.executable, "-m", "conda", "list", "--json"],
|
[str(conda_exe), "list", "-n", "dexorder", "--json"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
timeout=30,
|
timeout=30,
|
||||||
@@ -177,9 +182,20 @@ def install_packages(packages: list[str], data_dir: Optional[Path] = None) -> di
|
|||||||
# Install missing packages
|
# Install missing packages
|
||||||
log.info(f"Installing conda packages: {to_install}")
|
log.info(f"Installing conda packages: {to_install}")
|
||||||
|
|
||||||
|
conda_exe = get_conda_executable()
|
||||||
|
if not conda_exe:
|
||||||
|
log.error("Failed to install packages: conda executable not found")
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"installed": [],
|
||||||
|
"skipped": skipped,
|
||||||
|
"failed": to_install,
|
||||||
|
"error": "conda executable not found",
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[sys.executable, "-m", "conda", "install", "-y", "-c", "conda-forge"] + to_install,
|
[str(conda_exe), "install", "-y", "-n", "dexorder", "-c", "conda-forge"] + to_install,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
timeout=300, # 5 minute timeout
|
timeout=300, # 5 minute timeout
|
||||||
@@ -247,9 +263,18 @@ def remove_packages(packages: list[str]) -> dict:
|
|||||||
|
|
||||||
log.info(f"Removing conda packages: {packages}")
|
log.info(f"Removing conda packages: {packages}")
|
||||||
|
|
||||||
|
conda_exe = get_conda_executable()
|
||||||
|
if not conda_exe:
|
||||||
|
log.error("Failed to remove packages: conda executable not found")
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"removed": [],
|
||||||
|
"error": "conda executable not found",
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[sys.executable, "-m", "conda", "remove", "-y"] + packages,
|
[str(conda_exe), "remove", "-y", "-n", "dexorder"] + packages,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
timeout=120,
|
timeout=120,
|
||||||
|
|||||||
Reference in New Issue
Block a user