Skip to content

Commit

Permalink
Fix create/install commands for conda 23.9.0
Browse files Browse the repository at this point in the history
The `--experimental-solver` option was removed.
  • Loading branch information
nsoranzo committed Oct 11, 2023
1 parent ea2be33 commit 7fc4142
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/galaxy/tool_util/deps/conda_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)

import packaging.version
from packaging.version import Version

from galaxy.util import (
commands,
Expand Down Expand Up @@ -88,7 +89,7 @@ class CondaContext(installable.InstallableContext):
installable_description = "Conda"
_conda_build_available: Optional[bool]
_conda_version: Optional[Union[packaging.version.Version, packaging.version.LegacyVersion]]
_experimental_solver_available: Optional[bool]
_libmamba_solver_available: Optional[bool]

def __init__(
self,
Expand Down Expand Up @@ -129,7 +130,7 @@ def __init__(
def _reset_conda_properties(self) -> None:
self._conda_version = None
self._conda_build_available = None
self._experimental_solver_available = None
self._libmamba_solver_available = None

@property
def conda_version(self) -> Union[packaging.version.Version, packaging.version.LegacyVersion]:
Expand Down Expand Up @@ -167,13 +168,17 @@ def _override_channels_args(self) -> List[str]:
return override_channels_args

@property
def _experimental_solver_args(self) -> List[str]:
if self._experimental_solver_available is None:
self._experimental_solver_available = self.conda_version >= packaging.version.parse(
"4.12.0"
) and self.is_package_installed("conda-libmamba-solver")
if self._experimental_solver_available:
return ["--experimental-solver", "libmamba"]
def _solver_args(self) -> List[str]:
if self._libmamba_solver_available is None:
self._libmamba_solver_available = self.conda_version >= Version("4.12.0") and self.is_package_installed(
"conda-libmamba-solver"
)
if self._libmamba_solver_available:
# The "--solver" option was introduced in conda 22.11.0, when the
# "--experimental-solver" option was deprecated.
# The "--experimental-solver" option was removed in conda 23.9.0 .
solver_option = "--solver" if self.conda_version >= Version("22.11.0") else "--experimental-solver"
return [solver_option, "libmamba"]
else:
return []

Expand Down Expand Up @@ -288,7 +293,7 @@ def exec_create(self, args: Iterable[str], allow_local: bool = True, stdout_path
continue
if allow_local and self.use_local:
create_args.append("--use-local")
create_args.extend(self._experimental_solver_args)
create_args.extend(self._solver_args)
create_args.extend(self._override_channels_args)
create_args.extend(args)
ret = self.exec_command("create", create_args, stdout_path=stdout_path)
Expand Down Expand Up @@ -319,7 +324,7 @@ def exec_install(self, args: Iterable[str], allow_local: bool = True, stdout_pat
continue
if allow_local and self.use_local:
install_args.append("--use-local")
install_args.extend(self._experimental_solver_args)
install_args.extend(self._solver_args)
install_args.extend(self._override_channels_args)
install_args.extend(args)
ret = self.exec_command("install", install_args, stdout_path=stdout_path)
Expand Down

0 comments on commit 7fc4142

Please sign in to comment.