Esempio n. 1
0
def remove_actions(prefix, specs, index, force=False, pinned=True):
    r = Resolve(index)
    linked = [d+'.tar.bz2' for d in install.linked(prefix)]
    mss = list(map(MatchSpec, specs))

    if force:
        nlinked = {r.package_name(fn):fn[:-8] for fn in linked if not any(r.match(ms, fn) for ms in mss)}
    else:
        if config.track_features:
            specs.extend(x + '@' for x in config.track_features)
        nlinked = {r.package_name(fn):fn[:-8] for fn in r.remove(specs, linked)}

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)

    linked = {r.package_name(fn):fn[:-8] for fn in linked}

    actions = ensure_linked_actions(r.dependency_sort(nlinked), prefix)
    for old_fn in reversed(r.dependency_sort(linked)):
        dist = old_fn + '.tar.bz2'
        name = r.package_name(dist)
        if old_fn == nlinked.get(name,''):
            continue
        if pinned and any(r.match(ms, dist) for ms in pinned_specs):
            raise RuntimeError(
                "Cannot remove %s because it is pinned. Use --no-pin to override." % dist)
        if name == 'conda' and name not in nlinked:
            if any(ms.name == 'conda' for ms in mss):
                sys.exit("Error: 'conda' cannot be removed from the root environment")
            else:
                sys.exit("Error: this 'remove' command cannot be executed because it\nwould require removing 'conda' dependencies.")
        add_unlink(actions, old_fn)

    return actions
Esempio n. 2
0
def remove_actions(prefix, specs, index, force=False, pinned=True):
    r = Resolve(index)
    linked = [d + '.tar.bz2' for d in install.linked(prefix)]
    mss = list(map(MatchSpec, specs))

    if force:
        nlinked = {
            r.package_name(fn): fn[:-8]
            for fn in linked if not any(r.match(ms, fn) for ms in mss)
        }
    else:
        if config.track_features:
            specs.extend(x + '@' for x in config.track_features)
        nlinked = {
            r.package_name(fn): fn[:-8]
            for fn in r.remove(specs, linked)
        }

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)

    linked = {r.package_name(fn): fn[:-8] for fn in linked}

    actions = ensure_linked_actions(r.dependency_sort(nlinked), prefix)
    for old_fn in reversed(r.dependency_sort(linked)):
        dist = old_fn + '.tar.bz2'
        name = r.package_name(dist)
        if old_fn == nlinked.get(name, ''):
            continue
        if pinned and any(r.match(ms, dist) for ms in pinned_specs):
            raise RuntimeError(
                "Cannot remove %s because it is pinned. Use --no-pin to override."
                % dist)
        if name == 'conda' and name not in nlinked:
            if any(ms.name == 'conda' for ms in mss):
                sys.exit(
                    "Error: 'conda' cannot be removed from the root environment"
                )
            else:
                sys.exit(
                    "Error: this 'remove' command cannot be executed because it\nwould require removing 'conda' dependencies."
                )
        add_unlink(actions, old_fn)

    return actions
Esempio n. 3
0
def remove_actions(prefix, specs, index, force=False, pinned=True):
    r = Resolve(index)
    linked = r.installed

    if force:
        mss = list(map(MatchSpec, specs))
        nlinked = {
            r.package_name(fn): fn[:-8]
            for fn in linked if not any(r.match(ms, fn) for ms in mss)
        }
    else:
        add_defaults_to_specs(r, linked, specs, update=True)
        nlinked = {
            r.package_name(fn): fn[:-8]
            for fn in r.remove(specs, linked)
        }

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)

    linked = {r.package_name(fn): fn[:-8] for fn in linked}

    actions = ensure_linked_actions(r.dependency_sort(nlinked), prefix)
    for old_fn in reversed(r.dependency_sort(linked)):
        dist = old_fn + '.tar.bz2'
        name = r.package_name(dist)
        if old_fn == nlinked.get(name, ''):
            continue
        if pinned and any(r.match(ms, dist) for ms in pinned_specs):
            msg = "Cannot remove %s becaue it is pinned. Use --no-pin to override."
            raise RuntimeError(msg % dist)
        if name == 'conda' and name not in nlinked:
            if any(s.split(' ', 1)[0] == 'conda' for s in specs):
                sys.exit(
                    "Error: 'conda' cannot be removed from the root environment"
                )
            else:
                msg = (
                    "Error: this 'remove' command cannot be executed because it\n"
                    "would require removing 'conda' dependencies")
                sys.exit(msg)
        add_unlink(actions, old_fn)

    return actions
Esempio n. 4
0
def test_multiple_solution():
    index2 = index.copy()
    fn = 'pandas-0.11.0-np16py27_1.tar.bz2'
    res1 = set([fn])
    for k in range(1,15):
        fn2 = Dist('%s_%d.tar.bz2'%(fn[:-8],k))
        index2[fn2] = index[Dist(add_defaults_if_no_channel(fn))]
        res1.add(fn2)
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)
    res = r.solve(['pandas', 'python 2.7*', 'numpy 1.6*'], returnall=True)
    res = set([y for x in res for y in x if r.package_name(y).startswith('pandas')])
    assert len(res) <= len(res1)
Esempio n. 5
0
def test_multiple_solution():
    index2 = index.copy()
    fn = 'pandas-0.11.0-np16py27_1.tar.bz2'
    res1 = set([fn])
    for k in range(1,15):
        fn2 = Dist('%s_%d.tar.bz2'%(fn[:-8],k))
        index2[fn2] = index[Dist(fn)]
        res1.add(fn2)
    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r = Resolve(index2)
    res = r.solve(['pandas', 'python 2.7*', 'numpy 1.6*'], returnall=True)
    res = set([y for x in res for y in x if r.package_name(y).startswith('pandas')])
    assert len(res) <= len(res1)
Esempio n. 6
0
def remove_actions(prefix, specs, index, force=False, pinned=True):
    r = Resolve(index)
    linked = r.installed

    if force:
        mss = list(map(MatchSpec, specs))
        nlinked = {r.package_name(fn): fn[:-8]
                   for fn in linked
                   if not any(r.match(ms, fn) for ms in mss)}
    else:
        add_defaults_to_specs(r, linked, specs, update=True)
        nlinked = {r.package_name(fn): fn[:-8] for fn in r.remove(specs, linked)}

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)

    linked = {r.package_name(fn): fn[:-8] for fn in linked}

    actions = ensure_linked_actions(r.dependency_sort(nlinked), prefix)
    for old_fn in reversed(r.dependency_sort(linked)):
        dist = old_fn + '.tar.bz2'
        name = r.package_name(dist)
        if old_fn == nlinked.get(name, ''):
            continue
        if pinned and any(r.match(ms, dist) for ms in pinned_specs):
            msg = "Cannot remove %s becaue it is pinned. Use --no-pin to override."
            raise RuntimeError(msg % dist)
        if name == 'conda' and name not in nlinked:
            if any(s.split(' ', 1)[0] == 'conda' for s in specs):
                sys.exit("Error: 'conda' cannot be removed from the root environment")
            else:
                msg = ("Error: this 'remove' command cannot be executed because it\n"
                       "would require removing 'conda' dependencies")
                sys.exit(msg)
        add_unlink(actions, old_fn)

    return actions