Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.0] Fix create/install commands for conda 23.9.0 #16831

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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