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

Add support for wildcard (some*match) uninstalls #435

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 16 additions & 9 deletions conda_libmamba_solver/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,21 +544,28 @@ def early_exit(self) -> Dict[str, PackageRecord]:
"""
sis = self.solver_input_state
if sis.is_removing:
not_installed = [
spec for name, spec in sis.requested.items() if name not in sis.installed
]
# Make sure that requested packages to be removed match
# an installed record. Otherwise, raise an error.
# When 'remove --force' is set, remove the package without solving.
if sis.force_remove:
force_remove_solution = self.current_solution
not_installed = []
for name, spec in sis.requested.items():
for record in sis.installed.values():
if spec.match(record):
if sis.force_remove:
force_remove_solution.remove(record)
break
jezdez marked this conversation as resolved.
Show resolved Hide resolved
else:
not_installed.append(spec)

if not_installed:
exc = PackagesNotFoundError(not_installed)
exc.allow_retry = False
raise exc

if sis.force_remove:
for name, spec in sis.requested.items():
for record in sis.installed.values():
if spec.match(record):
self.records.pop(name)
break
return self.current_solution
return force_remove_solution

if sis.update_modifier.SPECS_SATISFIED_SKIP_SOLVE and not sis.is_removing:
for name, spec in sis.requested.items():
Expand Down
19 changes: 19 additions & 0 deletions news/435-remove-wildcard
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Allow wildcards in package names for `conda remove` (e.g. `conda remove "python-*"`). (#434 via #435)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
2 changes: 0 additions & 2 deletions tests/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from conda.common.compat import on_linux, on_win
from conda.common.io import env_var
from conda.core.prefix_data import PrefixData, get_python_version_for_prefix
from conda.exceptions import DryRunExit
from conda.testing.integration import (
Commands,
make_temp_env,
Expand All @@ -26,7 +25,6 @@

from conda_libmamba_solver import LibMambaSolver
from conda_libmamba_solver.exceptions import LibMambaUnsatisfiableError
from conda_libmamba_solver.mamba_utils import mamba_version

from .utils import conda_subprocess

Expand Down
Loading