def solve(specs: List[str], r: Resolve) -> Union[bool, Iterable[str]]: features = set() # type: Set for spec in specs: if conda.config.platform == 'win32' and spec == 'python': continue # XXX: This does not work when a spec only contains the name, # and different versions of the package have different features. ms = MatchSpec(spec) for pkg in r.get_pkgs(ms, max_only=False): fn = pkg.fn features.update(r.track_features(fn)) for spec in specs: for pkg in r.get_pkgs(MatchSpec(spec), max_only=False): fn = pkg.fn r.update_with_features(fn, features) print("Solving package specifications: ", end='') try: return r.explicit(specs) or r.solve2(specs, features, installed=(), minimal_hint=False, guess=False, unsat_only=True) except RuntimeError: print('\n') return False
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], config.track_features): dist = fn[:-8] name = install.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 or only_names or r.explicit(specs)): # ensure conda is in root environment assert 'conda' in must_have if install.on_win: for name in install.win_ignore_root: if name in must_have: del must_have[name] for name in config.foreign: if name in must_have: del must_have[name] else: # discard conda from other environments if 'conda' in must_have: sys.exit("Error: 'conda' can only be installed into " "root environment") 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 = install.name_dist(dist) if name in must_have and dist != must_have[name]: actions[UNLINK].append(dist) return actions