From c7394d7dc0e02c9be3da275a8e7a189115648383 Mon Sep 17 00:00:00 2001 From: Kale Franz Date: Mon, 22 Oct 2018 18:02:49 -0500 Subject: [PATCH] disable timestamp prioritization for non-conda-build use Signed-off-by: Kale Franz --- conda/base/context.py | 2 ++ conda/plan.py | 7 +++++-- conda/resolve.py | 15 +++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/conda/base/context.py b/conda/base/context.py index 5d1656af35e..d096524cf5a 100644 --- a/conda/base/context.py +++ b/conda/base/context.py @@ -207,6 +207,7 @@ class Context(Configuration): deps_modifier = PrimitiveParameter(DepsModifier.NOT_SET) update_modifier = PrimitiveParameter(UpdateModifier.UPDATE_SPECS) sat_solver = PrimitiveParameter(None, element_type=string_types + (NoneType,)) + solver_ignore_timestamps = PrimitiveParameter(True) # no_deps = PrimitiveParameter(NULL, element_type=(type(NULL), bool)) # CLI-only # only_deps = PrimitiveParameter(NULL, element_type=(type(NULL), bool)) # CLI-only @@ -743,6 +744,7 @@ def category_map(self): 'pip_interop_enabled', # temporary feature flag 'root_prefix', 'sat_solver', + 'solver_ignore_timestamps', 'subdir', 'subdirs', # https://conda.io/docs/config.html#disable-updating-of-dependencies-update-dependencies # NOQA diff --git a/conda/plan.py b/conda/plan.py index 2e7a2af0240..7358236cbef 100644 --- a/conda/plan.py +++ b/conda/plan.py @@ -21,7 +21,7 @@ from .base.constants import DEFAULTS_CHANNEL_NAME, UNKNOWN_CHANNEL from .base.context import context, reset_context from .common.compat import itervalues, text_type -from .common.io import env_var, time_recorder +from .common.io import env_vars, time_recorder from .core.index import LAST_CHANNEL_URLS, _supplement_index_with_prefix from .core.link import PrefixSetup, UnlinkLinkTransaction from .core.solve import diff_for_unlink_link_precs @@ -438,7 +438,10 @@ def install_actions(prefix, index, specs, force=False, only_names=None, always_c channel_priority_map=None, is_update=False, minimal_hint=False): # pragma: no cover # this is for conda-build - with env_var('CONDA_ALLOW_NON_CHANNEL_URLS', 'true', reset_context): + with env_vars({ + 'CONDA_ALLOW_NON_CHANNEL_URLS': 'true', + 'CONDA_SOLVER_IGNORE_TIMESTAMPS': 'false', + }, reset_context): from os.path import basename from ._vendor.boltons.setutils import IndexedSet from .core.solve import Solver diff --git a/conda/resolve.py b/conda/resolve.py index e06ea230bce..1a4eea10c14 100644 --- a/conda/resolve.py +++ b/conda/resolve.py @@ -42,6 +42,8 @@ def __init__(self, index, sort=False, processed=False, channels=()): self.channels = channels self._channel_priorities_map = self._make_channel_priorities(channels) if channels else {} + self._channel_priority = context.channel_priority + self._solver_ignore_timestamps = context.solver_ignore_timestamps groups = groupby("name", itervalues(index)) trackers = defaultdict(list) @@ -500,10 +502,15 @@ def version_key(self, prec, vtype=None): build_number = prec.get('build_number', 0) build_string = prec.get('build') ts = prec.get('timestamp', 0) - if context.channel_priority != ChannelPriority.DISABLED: - return valid, -channel_priority, version_comparator, build_number, ts, build_string + if self._channel_priority != ChannelPriority.DISABLED: + vkey = [valid, -channel_priority, version_comparator, build_number] else: - return valid, version_comparator, -channel_priority, build_number, ts, build_string + vkey = [valid, version_comparator, -channel_priority, build_number] + if self._solver_ignore_timestamps: + vkey.append(build_string) + else: + vkey.extend((ts, build_string)) + return vkey @staticmethod def _make_channel_priorities(channels): @@ -696,7 +703,7 @@ def generate_version_metrics(self, C, specs, include0=False): elif pkey[3] != version_key[3]: ib += 1 it = 0 - elif pkey[4] != version_key[4]: + elif not self._solver_ignore_timestamps and pkey[4] != version_key[4]: it += 1 prec_sat_name = self.to_sat_name(prec)