Skip to content
Open
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
32 changes: 6 additions & 26 deletions conda_libmamba_solver/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import re
import sys
from collections import defaultdict
from contextlib import suppress
from functools import cache
from inspect import stack
from itertools import chain
Expand All @@ -24,7 +23,6 @@

from conda import __version__ as _conda_version
from conda.base.constants import (
PREFIX_FROZEN_FILE,
REPODATA_FN,
UNKNOWN_CHANNEL,
ChannelPriority,
Expand All @@ -34,6 +32,7 @@
from conda.common.io import time_recorder
from conda.common.path import paths_equal
from conda.common.url import percent_decode
from conda.core.prefix_data import PrefixData
from conda.core.solve import Solver
from conda.exceptions import (
CondaValueError,
Expand All @@ -42,7 +41,7 @@
)
from conda.models.channel import Channel
from conda.models.match_spec import MatchSpec
from conda.models.records import PackageRecord, PrefixRecord
from conda.models.records import PackageRecord
from conda.models.version import VersionOrder
from conda.reporters import get_spinner
from libmambapy.solver import Request, Solution
Expand Down Expand Up @@ -1026,27 +1025,8 @@ def _notify_conda_outdated(
# This check can be silenced with a specific option in the context or in quiet mode
return

# manually check base prefix since `PrefixData(...).get("conda", None) is expensive
# once prefix data is lazy this might be a different situation
current_conda_prefix_rec = None
conda_self_installed = False
conda_frozen_file_found = os.path.exists(
os.path.join(context.root_prefix, PREFIX_FROZEN_FILE)
)
conda_meta_prefix_directory = os.path.join(context.root_prefix, "conda-meta")
with suppress(OSError, ValueError):
if os.path.lexists(conda_meta_prefix_directory):
for entry in os.scandir(conda_meta_prefix_directory):
if entry.is_file() and entry.name.endswith(".json"):
package_name = entry.name.rsplit("-", 2)[0]
if package_name == "conda":
with open(entry.path) as f:
current_conda_prefix_rec = PrefixRecord(**json.loads(f.read()))
elif package_name == "conda-self":
conda_self_installed = True
if conda_self_installed and current_conda_prefix_rec is not None:
# conda-self is installed and current conda has been found, no more information needed
break
prefix_data = PrefixData(context.root_prefix)
current_conda_prefix_rec = prefix_data.get("conda", None)

if not current_conda_prefix_rec:
# We are checking whether conda can be found in the environment conda is
Expand Down Expand Up @@ -1081,8 +1061,8 @@ def _notify_conda_outdated(
if conda_newer_records:
newest = max(conda_newer_records, key=lambda x: VersionOrder(x.version))
conda_update_message = f"conda update -n base -c {channel_name} conda"
if conda_frozen_file_found:
if conda_self_installed:
if prefix_data.is_frozen():
if prefix_data.get("conda-self", None):
conda_update_message = "conda self update"
else:
conda_update_message += " --override-frozen"
Expand Down
2 changes: 1 addition & 1 deletion dev/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pip
# run-time
boltons>=23.0.0
conda>=25.9
conda>=26.1
conda-forge::libmamba>=2.0.0
conda-forge::libmambapy>=2.0.0
msgpack-python>=1.1.1
Expand Down
19 changes: 19 additions & 0 deletions news/817-lazy-prefixdata
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

* Use lazy `PrefixData` getter to remove custom workaround for `conda` update checks. (#784 via #817)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
]
requires-python = ">=3.10"
dependencies = [
"conda >=25.9",
"conda >=26.1",
# "libmambapy >=2",
"boltons >=23.0.0",
"msgpack >=1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ requirements:
- hatch-vcs
run:
- python >=3.10
- conda >=25.9
- conda >=26.1
- libmambapy >=2.0.0
- boltons >=23.0.0
- msgpack-python >=1.1.1
Expand Down
Loading