diff --git a/lib/galaxy/tool_util/deps/conda_util.py b/lib/galaxy/tool_util/deps/conda_util.py index 1d9c1f74523e..6ccad9680c8e 100644 --- a/lib/galaxy/tool_util/deps/conda_util.py +++ b/lib/galaxy/tool_util/deps/conda_util.py @@ -21,6 +21,7 @@ ) import packaging.version +from packaging.version import Version from galaxy.util import ( commands, @@ -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, @@ -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]: @@ -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 [] @@ -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) @@ -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)