Skip to content

Commit

Permalink
Require libmambapy 1.5.3 (#347)
Browse files Browse the repository at this point in the history
* try with libmamba 1.5.3

* remove workarounds targeting earlier versions of libmamba

* remove skips and xfails for libmamba 1.5.x

* add news

* pre-commit

* also update in pyproject.toml

* remove unneeded continue
  • Loading branch information
jaimergp authored Nov 1, 2023
1 parent 442ea3c commit 2969b67
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 75 deletions.
21 changes: 8 additions & 13 deletions conda_libmamba_solver/mamba_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,20 @@ def init_api_context() -> api.Context:
api_ctx = api.Context()

# Output params
# We use this getattr() trick to guarantee backwards compatibility
# with libmambapy <=1.4.2; 1.4.3+ grouped some settings together
output_params = getattr(api_ctx, "output_params", api_ctx)
output_params.json = context.json
output_params.quiet = context.quiet
output_params.verbosity = context.verbosity
api_ctx.output_params.json = context.json
api_ctx.output_params.quiet = context.quiet
api_ctx.output_params.verbosity = context.verbosity
api_ctx.set_verbosity(context.verbosity)
if output_params.json:
if api_ctx.output_params.json:
api.cancel_json_output()

# Prefix params
prefix_params = getattr(api_ctx, "prefix_params", api_ctx)
prefix_params.conda_prefix = context.conda_prefix
prefix_params.root_prefix = context.root_prefix
prefix_params.target_prefix = context.target_prefix
api_ctx.prefix_params.conda_prefix = context.conda_prefix
api_ctx.prefix_params.root_prefix = context.root_prefix
api_ctx.prefix_params.target_prefix = context.target_prefix

# Networking params -- we always operate offline from libmamba's perspective
remote_fetch_params = getattr(api_ctx, "remote_fetch_params", api_ctx)
remote_fetch_params.user_agent = context.user_agent
api_ctx.remote_fetch_params.user_agent = context.user_agent
api_ctx.local_repodata_ttl = context.local_repodata_ttl
api_ctx.offline = True
api_ctx.use_index_cache = True
Expand Down
34 changes: 2 additions & 32 deletions conda_libmamba_solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,29 +371,12 @@ def _solve_attempt(
for (task_name, task_type), specs in tasks.items():
log.debug("Adding task %s with specs %s", task_name, specs)
if task_name == "ADD_PIN":
# ## Add pins
for spec in specs:
n_pins += 1
self.solver.add_pin(spec)
out_state.pins[f"pin-{n_pins}"] = spec
continue

try:
else:
self.solver.add_jobs(specs, task_type)
except RuntimeError as exc:
if mamba_version().startswith("1.5."):
for spec in specs:
if spec in str(exc):
break
else:
spec = f"One of {specs}"
msg = (
f"This is a bug in libmamba {mamba_version()} when using "
"'defaults::<spec>' or 'pkgs/main::<spec>'. "
"Consider using '-c defaults' instead."
)
raise InvalidMatchSpec(spec, msg)
raise

# ## Run solver
solved = self.solver.solve()
Expand Down Expand Up @@ -624,12 +607,7 @@ def _parse_problems(cls, problems: str) -> Mapping[str, MatchSpec]:
"""
conflicts = []
not_found = []
if "1.4.5" <= mamba_version() < "1.5.0":
# 1.4.5 had a regression where it would return
# a single line with all the problems; fixed in 1.5.0
problem_lines = [f" - {problem}" for problem in problems.split(" - ")[1:]]
else:
problem_lines = problems.splitlines()[1:]
problem_lines = problems.splitlines()[1:]
for line in problem_lines:
line = line.strip()
words = line.split()
Expand Down Expand Up @@ -729,14 +707,6 @@ def _prepare_problems_message(self, pins=None):
# This error makes 'explain_problems()' crash. Anticipate.
log.info("Failed to explain problems. Unsupported request.")
return legacy_errors
if (
mamba_version() <= "1.4.1"
and "conflicting requests" in self.solver.all_problems_to_str()
):
# This error makes 'explain_problems()' crash in libmamba <=1.4.1.
# Anticipate and return simpler error earlier.
log.info("Failed to explain problems. Conflicting requests.")
return legacy_errors
try:
explained_errors = self.solver.explain_problems()
except Exception as exc:
Expand Down
21 changes: 0 additions & 21 deletions dev/collect_upstream_conda_tests/collect_upstream_conda_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"""
pytest plugin to modify which upstream (conda/conda) tests are run by pytest.
"""
from importlib.metadata import version

import pytest

# Deselect tests from conda/conda we cannot pass due to different reasons
# These used to be skipped or xfail'd upstream, but we are trying to
Expand Down Expand Up @@ -107,15 +104,6 @@
}


_broken_by_libmamba_1_5_x = {
# conda/tests
"tests/test_export.py": [
"test_explicit",
"test_export",
],
}


def pytest_collection_modifyitems(session, config, items):
"""
We use this hook to modify which upstream tests (from the conda/conda repo)
Expand All @@ -131,15 +119,6 @@ def pytest_collection_modifyitems(session, config, items):
if item_name_no_brackets in _deselected_upstream_tests.get(path_key, []):
deselected.append(item)
continue
if version("libmambapy").startswith(
"1.5."
) and item_name_no_brackets in _broken_by_libmamba_1_5_x.get(path_key, []):
item.add_marker(
pytest.mark.xfail(
reason="Broken in libmamba 1.5.x; "
"see https://github.com/mamba-org/mamba/issues/2431."
)
)
selected.append(item)
items[:] = selected
config.hook.pytest_deselected(items=deselected)
4 changes: 2 additions & 2 deletions dev/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pip
# run-time
boltons>=23.0.0
conda>=23.7.3
libmamba>=1.5.1
libmambapy>=1.5.1
libmamba>=1.5.3
libmambapy>=1.5.3
# be explicit about sqlite because sometimes it's removed from the env :shrug:
sqlite
19 changes: 19 additions & 0 deletions news/347-libmamba-153-compat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* Require `libmambapy >=1.5.3` for improved signal handling and `MatchSpec` syntax compliance. (#347)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
requires-python = ">=3.8"
dependencies = [
"conda >=23.7.3",
"libmambapy >=1.5.1",
"libmambapy >=1.5.3",
"boltons >=23.0.0",
]
dynamic = [
Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ requirements:
run:
- python >=3.8
- conda >=23.7.3
- libmambapy >=1.5.1
- libmambapy >=1.5.3
- boltons >=23.0.0

test:
Expand Down
5 changes: 0 additions & 5 deletions tests/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ def test_python_downgrade_reinstalls_noarch_packages():
check_call([pip, "--version"])


@pytest.mark.xfail(
mamba_version().startswith("1.5."),
reason="Known bug. See https://github.com/mamba-org/mamba/issues/2431",
strict=True,
)
def test_defaults_specs_work():
"""
See https://github.com/conda/conda-libmamba-solver/issues/173
Expand Down

0 comments on commit 2969b67

Please sign in to comment.