def remove_actions(prefix, specs): linked = install.linked(prefix) mss = [MatchSpec(spec) for spec in specs] actions = defaultdict(list) actions[PREFIX] = prefix for dist in sorted(linked): if any(ms.match('%s.tar.bz2' % dist) for ms in mss): actions[UNLINK].append(dist) return actions
def remove_features_actions(prefix, index, features): linked = install.linked(prefix) r = Resolve(index) actions = defaultdict(list) actions[PREFIX] = prefix _linked = [d + '.tar.bz2' for d in linked] to_link = [] for dist in sorted(linked): fn = dist + '.tar.bz2' if fn not in index: continue if r.track_features(fn).intersection(features): actions[UNLINK].append(dist) if r.features(fn).intersection(features): actions[UNLINK].append(dist) subst = r.find_substitute(_linked, features, fn) if subst: to_link.append(subst[:-8]) if to_link: actions.update(ensure_linked_actions(to_link, prefix)) return actions
def install_actions(prefix, index, specs, force=False, only_names=None): r = Resolve(index) linked = install.linked(prefix) if is_root_prefix(prefix): specs.append('conda') add_defaults_to_specs(r, linked, specs) must_have = {} for fn in r.solve(specs, [d + '.tar.bz2' for d in linked]): dist = fn[:-8] name = name_dist(dist) if only_names and name not in only_names: continue must_have[name] = dist if is_root_prefix(prefix): if not force: # ensure conda is in root environment assert 'conda' in must_have else: # discard conda from other environments if 'conda' in must_have: del must_have['conda'] smh = sorted(must_have.values()) if force: actions = force_linked_actions(smh, index, prefix) else: actions = ensure_linked_actions(smh, prefix) for dist in sorted(linked): name = name_dist(dist) if name in must_have and dist != must_have[name]: actions[UNLINK].append(dist) return actions