예제 #1
0
파일: plan.py 프로젝트: dmj111/conda
def install_actions(prefix, index, specs, force=False, only_names=None):
    r = Resolve(index)
    linked = install.linked(prefix)

    # Here is a temporary fix to prevent adding conda to the specs;
    # Bootstrapping problem: conda is not available as a conda package for
    # py3k yet.
    import sys
    PY3 = sys.version_info[0] == 3

    if is_root_prefix(prefix) and not PY3:
        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) and not PY3:
        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
예제 #2
0
파일: plan.py 프로젝트: nvdnkpr/conda
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 or only_names):
            # 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]
    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
예제 #3
0
파일: plan.py 프로젝트: nvdnkpr/conda
def execute_plan(plan, index=None, verbose=False):
    if verbose:
        from conda.console import setup_handlers

        setup_handlers()

    progress_cmds = set([EXTRACT, RM_EXTRACTED, LINK, UNLINK])
    # set default prefix
    prefix = config.root_dir
    i = None
    cmds = cmds_from_plan(plan)

    for cmd, arg in cmds:
        if i is not None and cmd in progress_cmds:
            i += 1
            getLogger("progress.update").info((name_dist(arg), i))

        if cmd == PREFIX:
            prefix = arg
        elif cmd == PRINT:
            getLogger("print").info(arg)
        elif cmd == FETCH:
            fetch(index, arg)
        elif cmd == PROGRESS:
            i = 0
            maxval = int(arg)
            getLogger("progress.start").info(maxval)
        elif cmd == EXTRACT:
            install.extract(config.pkgs_dir, arg)
        elif cmd == RM_EXTRACTED:
            install.rm_extracted(config.pkgs_dir, arg)
        elif cmd == RM_FETCHED:
            install.rm_fetched(config.pkgs_dir, arg)
        elif cmd == LINK:
            link(prefix, arg)
        elif cmd == UNLINK:
            install.unlink(prefix, arg)
        else:
            raise Exception("Did not expect command: %r" % cmd)

        if i is not None and cmd in progress_cmds and maxval == i:
            i = None
            getLogger("progress.stop").info(None)

    install.messages(prefix)
예제 #4
0
파일: plan.py 프로젝트: dmj111/conda
def add_defaults_to_specs(r, linked, specs):
    if r.explicit(specs):
        return
    log.debug('H0 specs=%r' % specs)
    names_linked = {name_dist(dist): dist for dist in linked}
    names_ms = {MatchSpec(s).name: MatchSpec(s) for s in specs}

    for name, def_ver in [('python', config.default_python),
                          ('numpy', config.default_numpy)]:
        ms = names_ms.get(name)
        if ms and ms.strictness > 1:
            # if any of the specifications mention the Python/Numpy version,
            # we don't need to add the default spec
            log.debug('H1 %s' % name)
            continue

        any_depends_on = any(ms2.name == name
                             for spec in specs
                             for fn in r.get_max_dists(MatchSpec(spec))
                             for ms2 in r.ms_depends(fn))
        log.debug('H2 %s %s' % (name, any_depends_on))

        if not any_depends_on and name not in names_ms:
            # if nothing depends on Python/Numpy AND the Python/Numpy is not
            # specified, we don't need to add the default spec
            log.debug('H2A %s' % name)
            continue

        if (any_depends_on and len(specs) >= 1 and
                  MatchSpec(specs[0]).strictness == 3):
            # if something depends on Python/Numpy, but the spec is very
            # explicit, we also don't need to add the default spec
            log.debug('H2B %s' % name)
            continue

        if name in names_linked:
            # if Python/Numpy is already linked, we also don't need to add
            # the default
            log.debug('H3 %s' % name)
            specs.append(dist2spec3v(names_linked[name]))
            continue

        specs.append('%s %s*' % (name, def_ver))
    log.debug('HF specs=%r' % specs)