Skip to content

Commit c329139

Browse files
committed
Pass context.exclude_newer to libmambapy Database
Convert the exclude_newer duration/timestamp from conda's config into a Unix timestamp cutoff and pass it to libmambapy's Database constructor as exclude_newer_timestamp. This enables native --exclude-newer filtering in the libmamba solver backend. Depends on: - conda/conda#15761 (exclude_newer config + parse_duration_to_seconds) - mamba-org/mamba#4228 (exclude_newer_timestamp in Database::Settings)
1 parent 14207f7 commit c329139

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

conda_libmamba_solver/index.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,25 @@ def _init_db(self) -> Database:
347347
home_dir=str(Path.home()),
348348
current_working_dir=os.getcwd(),
349349
)
350-
db = Database(params)
350+
db = Database(
351+
params,
352+
exclude_newer_timestamp=self._exclude_newer_timestamp(),
353+
)
351354
db.set_logger(logger_callback)
352355
return db
353356

357+
@staticmethod
358+
def _exclude_newer_timestamp():
359+
"""Convert context.exclude_newer to a Unix timestamp for libmambapy."""
360+
value = context.exclude_newer
361+
if not value:
362+
return None
363+
import time
364+
365+
from conda.cli.helpers import parse_duration_to_seconds
366+
367+
return int(time.time() - parse_duration_to_seconds(value))
368+
354369
def _load_channels(
355370
self,
356371
urls_to_channel: dict[str, Channel] | None = None,

news/exclude-newer

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Enhancements
2+
3+
* Pass `context.exclude_newer` to libmambapy's `Database` as
4+
`exclude_newer_timestamp`, enabling native `--exclude-newer` support
5+
when the upstream mamba PR lands. (#15759)
6+
7+
### Bug fixes
8+
9+
* <news item>
10+
11+
### Deprecations
12+
13+
* <news item>
14+
15+
### Docs
16+
17+
* <news item>
18+
19+
### Other
20+
21+
* <news item>

0 commit comments

Comments
 (0)