示例#1
0
def test_circular_dependencies():
    index2 = index.copy()
    index2['package1-1.0-0.tar.bz2'] = {
        'build': '0',
        'build_number': 0,
        'depends': ['package2'],
        'name': 'package1',
        'requires': ['package2'],
        'version': '1.0',
    }
    index2['package2-1.0-0.tar.bz2'] = {
        'build': '0',
        'build_number': 0,
        'depends': ['package1'],
        'name': 'package2',
        'requires': ['package1'],
        'version': '1.0',
    }
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('package1'))) == {
        'package1-1.0-0.tar.bz2',
    }
    assert set(r.get_dists(['package1']).keys()) == {
        'package1-1.0-0.tar.bz2',
        'package2-1.0-0.tar.bz2',
    }
    assert r.solve(['package1']) == r.solve(['package2']) == \
        r.solve(['package1', 'package2']) == [
        'package1-1.0-0.tar.bz2',
        'package2-1.0-0.tar.bz2',
    ]
示例#2
0
def test_circular_dependencies():
    index2 = index.copy()
    index2["package1-1.0-0.tar.bz2"] = {
        "build": "0",
        "build_number": 0,
        "depends": ["package2"],
        "name": "package1",
        "requires": ["package2"],
        "version": "1.0",
    }
    index2["package2-1.0-0.tar.bz2"] = {
        "build": "0",
        "build_number": 0,
        "depends": ["package1"],
        "name": "package2",
        "requires": ["package1"],
        "version": "1.0",
    }
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec("package1"))) == {"package1-1.0-0.tar.bz2"}
    assert set(r.get_dists(["package1"]).keys()) == {"package1-1.0-0.tar.bz2", "package2-1.0-0.tar.bz2"}
    assert (
        r.solve(["package1"])
        == r.solve(["package2"])
        == r.solve(["package1", "package2"])
        == ["package1-1.0-0.tar.bz2", "package2-1.0-0.tar.bz2"]
    )
示例#3
0
def main():
    p = argparse.ArgumentParser()
    p.add_argument('pkg_fn', type=os.path.basename)
    p.add_argument('output_fn')
    p.add_argument('--dependsdata')
    p.add_argument('--index-cache', default='.index-cache.json')

    args = p.parse_args()

    r = Resolve(load_index(args.index_cache))
    with open(args.dependsdata) as f:
        dependsdata = json.load(f)

    try:
        plan = r.solve([_fn2fullspec(args.pkg_fn)],
                       features=set(),
                       installed=set(),
                       update_deps=False)

    except SystemExit:
        print('\n\n========wtf is this!\n\n')
        with open(args.output_fn, 'w') as f:
            json.dump({'pkg_fn': args.pkg_fn, 'unmet_depends': []}, f)
            return

    depends_provides = setreduce(dependsdata[fn]['provides'] for fn in plan)
    requires = setreduce(dependsdata[fn]['requires'] for fn in plan)

    with open(args.output_fn, 'w') as f:
        json.dump(
            {
                'pkg_fn': args.pkg_fn,
                'unmet_depends': list(requires - depends_provides)
            }, f)
示例#4
0
文件: plan.py 项目: andrew361x/conda
def install_actions(prefix, index, specs, force=False, only_names=None,
                    pinned=True, minimal_hint=False, update_deps=True):
    r = Resolve(index)
    linked = install.linked(prefix)

    if config.self_update and is_root_prefix(prefix):
        specs.append('conda')

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)
        specs += pinned_specs
        # TODO: Improve error messages here
    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, minimal_hint=minimal_hint,
                      update_deps=update_deps):
        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 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]
    elif basename(prefix).startswith('_'):
        # anything (including conda) can be installed into environments
        # starting with '_', mainly to allow conda-build to build conda
        pass
    else:
        # disallow conda from being installed into all other environments
        if 'conda' in must_have:
            sys.exit("Error: 'conda' can only be installed into the "
                     "root environment")

    smh = r.graph_sort(must_have)

    if force:
        actions = force_linked_actions(smh, index, prefix)
    else:
        actions = ensure_linked_actions(smh, prefix)

    if actions[inst.LINK] and sys.platform != 'win32' and prefix != config.root_dir:
        actions[inst.SYMLINK_CONDA] = [config.root_dir]

    for dist in sorted(linked):
        name = install.name_dist(dist)
        if name in must_have and dist != must_have[name]:
            add_unlink(actions, dist)

    return actions
示例#5
0
文件: plan.py 项目: DPeterK/conda
def install_actions(prefix,
                    index,
                    specs,
                    force=False,
                    only_names=None,
                    pinned=True,
                    minimal_hint=False):

    r = Resolve(index)
    linked = install.linked(prefix)

    if config.self_update and is_root_prefix(prefix):
        specs.append('conda')
    add_defaults_to_specs(r, linked, specs)
    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        specs += pinned_specs
        # TODO: Improve error messages here

    must_have = {}
    for fn in r.solve(specs, [d + '.tar.bz2' for d in linked],
                      config.track_features,
                      minimal_hint=minimal_hint):
        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 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 = r.graph_sort(must_have)

    if force:
        actions = force_linked_actions(smh, index, prefix)
    else:
        actions = ensure_linked_actions(smh, prefix)

    if actions[inst.LINK] and sys.platform != 'win32':
        actions[inst.SYMLINK_CONDA] = [config.root_dir]

    for dist in sorted(linked):
        name = install.name_dist(dist)
        if name in must_have and dist != must_have[name]:
            actions[inst.UNLINK].append(dist)

    return actions
示例#6
0
def main():
    r = Resolve(get_index())
    plan = r.solve(['anaconda 2.4.1'],
                   features=set(),
                   installed=set(),
                   update_deps=True)
    for fn in plan:
        print(os.path.join('tarballs', fn))
示例#7
0
文件: plan.py 项目: bhuber2010/conda
def install_actions(prefix, index, specs, force=False, only_names=None,
                    pinned=True, minimal_hint=False):
    r = Resolve(index)
    linked = install.linked(prefix)

    if config.self_update and is_root_prefix(prefix):
        specs.append('conda')

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)
        specs += pinned_specs
        # TODO: Improve error messages here
    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, minimal_hint=minimal_hint):
        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 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]
    elif basename(prefix).startswith('_'):
        # anything (including conda) can be installed into environments
        # starting with '_', mainly to allow conda-build to build conda
        pass
    else:
        # disallow conda from being installed into all other environments
        if 'conda' in must_have:
            sys.exit("Error: 'conda' can only be installed into the "
                     "root environment")

    smh = r.graph_sort(must_have)

    if force:
        actions = force_linked_actions(smh, index, prefix)
    else:
        actions = ensure_linked_actions(smh, prefix)

    if actions[inst.LINK] and sys.platform != 'win32' and prefix != config.root_dir:
        actions[inst.SYMLINK_CONDA] = [config.root_dir]

    for dist in sorted(linked):
        name = install.name_dist(dist)
        if name in must_have and dist != must_have[name]:
            add_unlink(actions, dist)

    return actions
示例#8
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 = '%s_%d.tar.bz2'%(fn[:-8],k)
        index2[fn2] = index[fn]
        res1.add(fn2)
    r = Resolve(index2)
    res = r.solve(['pandas', 'python 2.7*', 'numpy 1.6*'], returnall=True)
    res = set([x[3] for x in res])
    assert res <= res1
示例#9
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 = '%s_%d.tar.bz2' % (fn[:-8], k)
        index2[fn2] = index[fn]
        res1.add(fn2)
    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 y.startswith('pandas')])
    assert res <= res1
示例#10
0
文件: plan.py 项目: drbenmorgan/conda
def install_actions(prefix, index, specs, force=False, only_names=None, pinned=True, minimal_hint=False):

    r = Resolve(index)
    linked = install.linked(prefix)

    if config.self_update and is_root_prefix(prefix):
        specs.append('conda')
    add_defaults_to_specs(r, linked, specs)
    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        specs += pinned_specs
        # TODO: Improve error messages here

    must_have = {}
    for fn in r.solve(specs, [d + '.tar.bz2' for d in linked],
                      config.track_features, minimal_hint=minimal_hint):
        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 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 = r.graph_sort(must_have)

    if force:
        actions = force_linked_actions(smh, index, prefix)
    else:
        actions = ensure_linked_actions(smh, prefix)

    if actions[LINK] and sys.platform != 'win32':
        actions[SYMLINK_CONDA] = [config.root_dir]

    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
示例#11
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)
示例#12
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)
示例#13
0
def resolve(info):
    if not index:
        sys.exit("Error: index is empty, maybe 'channels' are missing?")
    specs = info['specs']
    r = Resolve(index)
    add_defaults_to_specs(r, [], specs)
    res = list(r.solve(specs))
    sys.stdout.write('\n')

    if 'install_in_dependency_order' in info:
        sort_info = {name_dist(d): d[:-8] for d in res}
        dists.extend(d + '.tar.bz2' for d in r.graph_sort(sort_info))
    else:
        dists.extend(res)
示例#14
0
def test_install_package_with_feature():
    index2 = index.copy()
    index2['mypackage-1.0-featurepy33_0.tar.bz2'] = {
        'build': 'featurepy33_0',
        'build_number': 0,
        'depends': ['python 3.3*'],
        'name': 'mypackage',
        'version': '1.0',
        'features': 'feature',
    }
    index2['feature-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['python 3.3*'],
        'name': 'mypackage',
        'version': '1.0',
        'track_features': 'feature',
    }

    r = Resolve(index2)

    # It should not raise
    r.solve(['mypackage'], installed=['feature-1.0-py33_0.tar.bz2'])
示例#15
0
def resolve(info):
    if not index:
        sys.exit("Error: index is empty, maybe 'channels' are missing?")
    specs = info['specs']
    r = Resolve(index)
    add_defaults_to_specs(r, [], specs)
    res = list(r.solve(specs))
    sys.stdout.write('\n')

    if 'install_in_dependency_order' in info:
        sort_info = {name_dist(d): d[:-8] for d in res}
        dists.extend(d + '.tar.bz2' for d in r.graph_sort(sort_info))
    else:
        dists.extend(res)
示例#16
0
def test_install_package_with_feature():
    index2 = index.copy()
    index2["mypackage-1.0-featurepy33_0.tar.bz2"] = {
        "build": "featurepy33_0",
        "build_number": 0,
        "depends": ["python 3.3*"],
        "name": "mypackage",
        "version": "1.0",
        "features": "feature",
    }
    index2["feature-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["python 3.3*"],
        "name": "mypackage",
        "version": "1.0",
        "track_features": "feature",
    }

    r = Resolve(index2)

    # It should not raise
    r.solve(["mypackage"], installed=["feature-1.0-py33_0.tar.bz2"])
示例#17
0
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
示例#18
0
def resolve(info):
    """
    sets global DISTS and INDEX
    """
    global DISTS

    specs = info['specs']
    r = Resolve(INDEX)
    add_defaults_to_specs(r, [], specs)
    DISTS = list(r.solve(specs))

    sort_info = {}
    for d in DISTS:
        name, unused_version, unused_build = d.rsplit('-', 2)
        sort_info[name] = d.rsplit('.tar.bz2', 1)[0]

    DISTS = map(lambda d: d + '.tar.bz2', r.graph_sort(sort_info))
示例#19
0
文件: plan.py 项目: hihihippp/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],
                      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
示例#20
0
文件: api.py 项目: dmj111/conda
def app_info_packages(fn):
    """
    given the filename of a package, return which packages (and their sizes)
    still need to be downloaded, in order to install the package.  That is,
    the package itself and it's dependencies.
    Returns a list of tuples (pkg_name, pkg_version, size,
    fetched? True or False).
    """
    from conda.resolve import Resolve

    index = get_index()
    r = Resolve(index)
    res = []
    for fn2 in r.solve([fn2spec(fn)]):
        info = index[fn2]
        res.append((info['name'], info['version'], info['size'],
                    install.is_fetched(config.pkgs_dir, fn2[:-8])))
    return res
示例#21
0
def app_info_packages(fn):
    """
    given the filename of a package, return which packages (and their sizes)
    still need to be downloaded, in order to install the package.  That is,
    the package itself and it's dependencies.
    Returns a list of tuples (pkg_name, pkg_version, size,
    fetched? True or False).
    """
    from conda.resolve import Resolve

    index = get_index()
    r = Resolve(index)
    res = []
    for fn2 in r.solve([_fn2fullspec(fn)]):
        info = index[fn2]
        res.append((info['name'], info['version'], info['size'],
                    any(install.is_fetched(pkgs_dir, fn2[:-8])
                        for pkgs_dir in config.pkgs_dirs)))
    return res
示例#22
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
示例#23
0
文件: api.py 项目: 3kwa/conda
def app_info_packages(fn, prefix=config.root_dir):
    """
    given the filename of a package, return which packages (and their sizes)
    still need to be downloaded, in order to install the package.  That is,
    the package itself and it's dependencies.
    Returns a list of tuples (pkg_name, pkg_version, size,
    fetched? True or False).
    """
    from conda.resolve import Resolve

    index = get_index(prefix=prefix)
    r = Resolve(index)
    res = []
    for fn2 in r.solve([_fn2fullspec(fn)], installed=install.linked(prefix)):
        info = index[fn2]
        if 'link' not in info:
            res.append((info['name'], info['version'], info['size'],
                        any(install.is_fetched(pkgs_dir, fn2[:-8])
                            for pkgs_dir in config.pkgs_dirs)))
    return res
示例#24
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
示例#25
0
def test_no_features():
    # Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'.
    assert r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*'],
        returnall=True) == [[Dist(add_defaults_if_no_channel(fname)) for fname in [
            'numpy-1.6.2-py26_4.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2',
            'python-2.6.8-6.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'scipy-0.11.0-np16py26_3.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]]

    assert r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*', 'mkl@'],
        returnall=True) == [[Dist(add_defaults_if_no_channel(fname)) for fname in [
            'mkl-rt-11.0-p0.tar.bz2',           # This,
            'numpy-1.6.2-py26_p4.tar.bz2',      # this,
            'openssl-1.0.1c-0.tar.bz2',
            'python-2.6.8-6.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'scipy-0.11.0-np16py26_p3.tar.bz2', # and this are different.
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]]

    index2 = index.copy()
    index2["defaults::pandas-0.12.0-np16py27_0.tar.bz2"] = IndexRecord(**{
            "build": "np16py27_0",
            "build_number": 0,
            "depends": [
              "dateutil",
              "numpy 1.6*",
              "python 2.7*",
              "pytz"
            ],
            "name": "pandas",
            "requires": [
              "dateutil 1.5",
              "numpy 1.6",
              "python 2.7",
              "pytz"
            ],
            "version": "0.12.0"
        })
    # Make it want to choose the pro version by having it be newer.
    index2["defaults::numpy-1.6.2-py27_p5.tar.bz2"] = IndexRecord(**{
            "build": "py27_p5",
            "build_number": 5,
            "depends": [
              "mkl-rt 11.0",
              "python 2.7*"
            ],
            "features": "mkl",
            "name": "numpy",
            "pub_date": "2013-04-29",
            "requires": [
              "mkl-rt 11.0",
              "python 2.7"
            ],
            "version": "1.6.2"
        })

    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r2 = Resolve(index2)

    # This should not pick any mkl packages (the difference here is that none
    # of the specs directly have mkl versions)
    assert r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*'],
        returnall=True) == [[Dist(add_defaults_if_no_channel(fname)) for fname in [
            'dateutil-2.1-py27_1.tar.bz2',
            'numpy-1.6.2-py27_4.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2',
            'pandas-0.12.0-np16py27_0.tar.bz2',
            'python-2.7.5-0.tar.bz2',
            'pytz-2013b-py27_0.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]]

    assert r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*', 'mkl@'],
        returnall=True)[0] == [[Dist(add_defaults_if_no_channel(fname)) for fname in [
            'dateutil-2.1-py27_1.tar.bz2',
            'mkl-rt-11.0-p0.tar.bz2',           # This
            'numpy-1.6.2-py27_p5.tar.bz2',      # and this are different.
            'openssl-1.0.1c-0.tar.bz2',
            'pandas-0.12.0-np16py27_0.tar.bz2',
            'python-2.7.5-0.tar.bz2',
            'pytz-2013b-py27_0.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]][0]
示例#26
0
def test_no_features():
    # Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'.
    assert r.solve(["python 2.6*", "numpy 1.6*", "scipy 0.11*"], returnall=True) == [
        [
            "numpy-1.6.2-py26_4.tar.bz2",
            "openssl-1.0.1c-0.tar.bz2",
            "python-2.6.8-6.tar.bz2",
            "readline-6.2-0.tar.bz2",
            "scipy-0.11.0-np16py26_3.tar.bz2",
            "sqlite-3.7.13-0.tar.bz2",
            "system-5.8-1.tar.bz2",
            "tk-8.5.13-0.tar.bz2",
            "zlib-1.2.7-0.tar.bz2",
        ]
    ]

    assert r.solve(["python 2.6*", "numpy 1.6*", "scipy 0.11*", "mkl@"], returnall=True) == [
        [
            "mkl-rt-11.0-p0.tar.bz2",  # This,
            "numpy-1.6.2-py26_p4.tar.bz2",  # this,
            "openssl-1.0.1c-0.tar.bz2",
            "python-2.6.8-6.tar.bz2",
            "readline-6.2-0.tar.bz2",
            "scipy-0.11.0-np16py26_p3.tar.bz2",  # and this are different.
            "sqlite-3.7.13-0.tar.bz2",
            "system-5.8-1.tar.bz2",
            "tk-8.5.13-0.tar.bz2",
            "zlib-1.2.7-0.tar.bz2",
        ]
    ]

    index2 = index.copy()
    index2["pandas-0.12.0-np16py27_0.tar.bz2"] = {
        "build": "np16py27_0",
        "build_number": 0,
        "depends": ["dateutil", "numpy 1.6*", "python 2.7*", "pytz"],
        "name": "pandas",
        "requires": ["dateutil 1.5", "numpy 1.6", "python 2.7", "pytz"],
        "version": "0.12.0",
    }
    # Make it want to choose the pro version by having it be newer.
    index2["numpy-1.6.2-py27_p5.tar.bz2"] = {
        "build": "py27_p5",
        "build_number": 5,
        "depends": ["mkl-rt 11.0", "python 2.7*"],
        "features": "mkl",
        "name": "numpy",
        "pub_date": "2013-04-29",
        "requires": ["mkl-rt 11.0", "python 2.7"],
        "version": "1.6.2",
    }

    r2 = Resolve(index2)

    # This should not pick any mkl packages (the difference here is that none
    # of the specs directly have mkl versions)
    assert r2.solve(["pandas 0.12.0 np16py27_0", "python 2.7*"], returnall=True) == [
        [
            "dateutil-2.1-py27_1.tar.bz2",
            "numpy-1.6.2-py27_4.tar.bz2",
            "openssl-1.0.1c-0.tar.bz2",
            "pandas-0.12.0-np16py27_0.tar.bz2",
            "python-2.7.5-0.tar.bz2",
            "pytz-2013b-py27_0.tar.bz2",
            "readline-6.2-0.tar.bz2",
            "six-1.3.0-py27_0.tar.bz2",
            "sqlite-3.7.13-0.tar.bz2",
            "system-5.8-1.tar.bz2",
            "tk-8.5.13-0.tar.bz2",
            "zlib-1.2.7-0.tar.bz2",
        ]
    ]

    assert (
        r2.solve(["pandas 0.12.0 np16py27_0", "python 2.7*", "mkl@"], returnall=True)[0]
        == [
            [
                "dateutil-2.1-py27_1.tar.bz2",
                "mkl-rt-11.0-p0.tar.bz2",  # This
                "numpy-1.6.2-py27_p5.tar.bz2",  # and this are different.
                "openssl-1.0.1c-0.tar.bz2",
                "pandas-0.12.0-np16py27_0.tar.bz2",
                "python-2.7.5-0.tar.bz2",
                "pytz-2013b-py27_0.tar.bz2",
                "readline-6.2-0.tar.bz2",
                "six-1.3.0-py27_0.tar.bz2",
                "sqlite-3.7.13-0.tar.bz2",
                "system-5.8-1.tar.bz2",
                "tk-8.5.13-0.tar.bz2",
                "zlib-1.2.7-0.tar.bz2",
            ]
        ][0]
    )
示例#27
0
def test_nonexistent_deps():
    index2 = index.copy()
    index2["mypackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*", "notarealpackage 2.0*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.0",
    }
    index2["mypackage-1.1-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.1",
    }
    index2["anotherpackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage 1.1"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage 1.1"],
        "version": "1.0",
    }
    index2["anotherpackage-2.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage"],
        "version": "2.0",
    }
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec("mypackage"))) == {
        "mypackage-1.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
    }
    assert set(r.get_dists(["mypackage"]).keys()) == {
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.1.2-py26_0.tar.bz2",
        "nose-1.1.2-py27_0.tar.bz2",
        "nose-1.1.2-py33_0.tar.bz2",
        "nose-1.2.1-py26_0.tar.bz2",
        "nose-1.2.1-py27_0.tar.bz2",
        "nose-1.2.1-py33_0.tar.bz2",
        "nose-1.3.0-py26_0.tar.bz2",
        "nose-1.3.0-py27_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-2.6.8-1.tar.bz2",
        "python-2.6.8-2.tar.bz2",
        "python-2.6.8-3.tar.bz2",
        "python-2.6.8-4.tar.bz2",
        "python-2.6.8-5.tar.bz2",
        "python-2.6.8-6.tar.bz2",
        "python-2.7.3-2.tar.bz2",
        "python-2.7.3-3.tar.bz2",
        "python-2.7.3-4.tar.bz2",
        "python-2.7.3-5.tar.bz2",
        "python-2.7.3-6.tar.bz2",
        "python-2.7.3-7.tar.bz2",
        "python-2.7.4-0.tar.bz2",
        "python-2.7.5-0.tar.bz2",
        "python-3.3.0-2.tar.bz2",
        "python-3.3.0-3.tar.bz2",
        "python-3.3.0-4.tar.bz2",
        "python-3.3.0-pro0.tar.bz2",
        "python-3.3.0-pro1.tar.bz2",
        "python-3.3.1-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    }

    assert set(r.get_dists(["mypackage"], max_only=True).keys()) == {
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.3.0-py26_0.tar.bz2",
        "nose-1.3.0-py27_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-2.6.8-6.tar.bz2",
        "python-2.7.5-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    }

    assert (
        r.solve(["mypackage"])
        == r.solve(["mypackage 1.1"])
        == [
            "mypackage-1.1-py33_0.tar.bz2",
            "nose-1.3.0-py33_0.tar.bz2",
            "openssl-1.0.1c-0.tar.bz2",
            "python-3.3.2-0.tar.bz2",
            "readline-6.2-0.tar.bz2",
            "sqlite-3.7.13-0.tar.bz2",
            "system-5.8-1.tar.bz2",
            "tk-8.5.13-0.tar.bz2",
            "zlib-1.2.7-0.tar.bz2",
        ]
    )
    assert raises(NoPackagesFound, lambda: r.solve(["mypackage 1.0"]))

    assert r.solve(["anotherpackage 1.0"]) == [
        "anotherpackage-1.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    ]

    assert r.solve(["anotherpackage"]) == [
        "anotherpackage-2.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    ]

    # This time, the latest version is messed up
    index3 = index.copy()
    index3["mypackage-1.1-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*", "notarealpackage 2.0*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.1",
    }
    index3["mypackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "python 3.3*"],
        "name": "mypackage",
        "requires": ["nose 1.2.1", "python 3.3"],
        "version": "1.0",
    }
    index3["anotherpackage-1.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage 1.0"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage 1.0"],
        "version": "1.0",
    }
    index3["anotherpackage-2.0-py33_0.tar.bz2"] = {
        "build": "py33_0",
        "build_number": 0,
        "depends": ["nose", "mypackage"],
        "name": "anotherpackage",
        "requires": ["nose", "mypackage"],
        "version": "2.0",
    }
    r = Resolve(index3)

    assert set(r.find_matches(MatchSpec("mypackage"))) == {
        "mypackage-1.0-py33_0.tar.bz2",
        "mypackage-1.1-py33_0.tar.bz2",
    }
    assert set(r.get_dists(["mypackage"]).keys()) == {
        "mypackage-1.0-py33_0.tar.bz2",
        "nose-1.1.2-py26_0.tar.bz2",
        "nose-1.1.2-py27_0.tar.bz2",
        "nose-1.1.2-py33_0.tar.bz2",
        "nose-1.2.1-py26_0.tar.bz2",
        "nose-1.2.1-py27_0.tar.bz2",
        "nose-1.2.1-py33_0.tar.bz2",
        "nose-1.3.0-py26_0.tar.bz2",
        "nose-1.3.0-py27_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-2.6.8-1.tar.bz2",
        "python-2.6.8-2.tar.bz2",
        "python-2.6.8-3.tar.bz2",
        "python-2.6.8-4.tar.bz2",
        "python-2.6.8-5.tar.bz2",
        "python-2.6.8-6.tar.bz2",
        "python-2.7.3-2.tar.bz2",
        "python-2.7.3-3.tar.bz2",
        "python-2.7.3-4.tar.bz2",
        "python-2.7.3-5.tar.bz2",
        "python-2.7.3-6.tar.bz2",
        "python-2.7.3-7.tar.bz2",
        "python-2.7.4-0.tar.bz2",
        "python-2.7.5-0.tar.bz2",
        "python-3.3.0-2.tar.bz2",
        "python-3.3.0-3.tar.bz2",
        "python-3.3.0-4.tar.bz2",
        "python-3.3.0-pro0.tar.bz2",
        "python-3.3.0-pro1.tar.bz2",
        "python-3.3.1-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    }

    assert raises(NoPackagesFound, lambda: r.get_dists(["mypackage"], max_only=True))

    assert (
        r.solve(["mypackage"])
        == r.solve(["mypackage 1.0"])
        == [
            "mypackage-1.0-py33_0.tar.bz2",
            "nose-1.3.0-py33_0.tar.bz2",
            "openssl-1.0.1c-0.tar.bz2",
            "python-3.3.2-0.tar.bz2",
            "readline-6.2-0.tar.bz2",
            "sqlite-3.7.13-0.tar.bz2",
            "system-5.8-1.tar.bz2",
            "tk-8.5.13-0.tar.bz2",
            "zlib-1.2.7-0.tar.bz2",
        ]
    )
    assert raises(NoPackagesFound, lambda: r.solve(["mypackage 1.1"]))

    assert r.solve(["anotherpackage 1.0"]) == [
        "anotherpackage-1.0-py33_0.tar.bz2",
        "mypackage-1.0-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    ]

    # If recursive checking is working correctly, this will give
    # anotherpackage 2.0, not anotherpackage 1.0
    assert r.solve(["anotherpackage"]) == [
        "anotherpackage-2.0-py33_0.tar.bz2",
        "mypackage-1.0-py33_0.tar.bz2",
        "nose-1.3.0-py33_0.tar.bz2",
        "openssl-1.0.1c-0.tar.bz2",
        "python-3.3.2-0.tar.bz2",
        "readline-6.2-0.tar.bz2",
        "sqlite-3.7.13-0.tar.bz2",
        "system-5.8-1.tar.bz2",
        "tk-8.5.13-0.tar.bz2",
        "zlib-1.2.7-0.tar.bz2",
    ]
示例#28
0
文件: plan.py 项目: Studiogit/conda
    r = Resolve(index)
    linked = install.linked(prefix)

    if config.self_update and is_root_prefix(prefix):
        specs.append('conda')

    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s" % pinned_specs)
        specs += pinned_specs
        # TODO: Improve error messages here
    add_defaults_to_specs(r, linked, specs)

    must_have = {}
    mustnt_have = {}
    for fn in r.solve(specs, [d + '.tar.bz2' for d in linked],
                      config.track_features, minimal_hint=minimal_hint,
                      update_deps=update_deps):
        dist = fn[:-8]
        name = install.name_dist(dist)
        if name.startswith('remove '):
            name = name.split('remove ', 1)[1]
            dist = dist.split('remove ', 1)[1]
            mustnt_have[name] = dist
        else:
            if only_names and name not in only_names:
                continue
            must_have[name] = dist

    if is_root_prefix(prefix):
        for name in config.foreign:
示例#29
0
def test_no_features():
    # Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'.
    assert r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*'],
        returnall=True) == [[Dist(fname) for fname in [
            'numpy-1.6.2-py26_4.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2',
            'python-2.6.8-6.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'scipy-0.11.0-np16py26_3.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]]

    assert r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*', 'mkl@'],
        returnall=True) == [[Dist(fname) for fname in [
            'mkl-rt-11.0-p0.tar.bz2',           # This,
            'numpy-1.6.2-py26_p4.tar.bz2',      # this,
            'openssl-1.0.1c-0.tar.bz2',
            'python-2.6.8-6.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'scipy-0.11.0-np16py26_p3.tar.bz2', # and this are different.
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]]

    index2 = index.copy()
    index2["pandas-0.12.0-np16py27_0.tar.bz2"] = Record(**{
            "build": "np16py27_0",
            "build_number": 0,
            "depends": [
              "dateutil",
              "numpy 1.6*",
              "python 2.7*",
              "pytz"
            ],
            "name": "pandas",
            "requires": [
              "dateutil 1.5",
              "numpy 1.6",
              "python 2.7",
              "pytz"
            ],
            "version": "0.12.0"
        })
    # Make it want to choose the pro version by having it be newer.
    index2["numpy-1.6.2-py27_p5.tar.bz2"] = Record(**{
            "build": "py27_p5",
            "build_number": 5,
            "depends": [
              "mkl-rt 11.0",
              "python 2.7*"
            ],
            "features": "mkl",
            "name": "numpy",
            "pub_date": "2013-04-29",
            "requires": [
              "mkl-rt 11.0",
              "python 2.7"
            ],
            "version": "1.6.2"
        })

    index2 = {Dist(key): value for key, value in iteritems(index2)}
    r2 = Resolve(index2)

    # This should not pick any mkl packages (the difference here is that none
    # of the specs directly have mkl versions)
    assert r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*'],
        returnall=True) == [[Dist(fname) for fname in [
            'dateutil-2.1-py27_1.tar.bz2',
            'numpy-1.6.2-py27_4.tar.bz2',
            'openssl-1.0.1c-0.tar.bz2',
            'pandas-0.12.0-np16py27_0.tar.bz2',
            'python-2.7.5-0.tar.bz2',
            'pytz-2013b-py27_0.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]]

    assert r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*', 'mkl@'],
        returnall=True)[0] == [[Dist(fname) for fname in [
            'dateutil-2.1-py27_1.tar.bz2',
            'mkl-rt-11.0-p0.tar.bz2',           # This
            'numpy-1.6.2-py27_p5.tar.bz2',      # and this are different.
            'openssl-1.0.1c-0.tar.bz2',
            'pandas-0.12.0-np16py27_0.tar.bz2',
            'python-2.7.5-0.tar.bz2',
            'pytz-2013b-py27_0.tar.bz2',
            'readline-6.2-0.tar.bz2',
            'six-1.3.0-py27_0.tar.bz2',
            'sqlite-3.7.13-0.tar.bz2',
            'system-5.8-1.tar.bz2',
            'tk-8.5.13-0.tar.bz2',
            'zlib-1.2.7-0.tar.bz2',
            ]]][0]
示例#30
0
import conda


from conda.api import get_index
from conda.fetch import fetch_repodata

url = 'file:///data/local/itpe/miniconda/conda-builds-scientific_software_stack_since_05_15/linux-64/'
repo = fetch_repodata(url)

from conda.resolve import Resolve, MatchSpec

print repo

r = Resolve(repo['packages'])
r.solve(env_lts['packages'], features=set())

r.solve2(env_lts['packages'], features=set())

# conda.api.fetch_repodata is the underlying index loader.



#index = get_index(channel_urls=channel_urls,
#                              prepend=not args.override_channels,
#                              use_cache=args.use_index_cache,
#                              unknown=args.unknown,
#                              json=args.json,
#                              offline=args.offline)

示例#31
0
def test_nonexistent_deps():
    index2 = index.copy()
    index2['mypackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    }
    index2['mypackage-1.1-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    }
    index2['anotherpackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.1'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.1'],
        'version': '1.0',
    }
    index2['anotherpackage-2.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    }
    r = Resolve(index2)

    assert set(r.find_matches(MatchSpec('mypackage'))) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
    }
    assert set(r.get_dists(['mypackage']).keys()) == {
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.1.2-py26_0.tar.bz2',
        'nose-1.1.2-py27_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py26_0.tar.bz2',
        'nose-1.2.1-py27_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py26_0.tar.bz2',
        'nose-1.3.0-py27_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.6.8-1.tar.bz2',
        'python-2.6.8-2.tar.bz2',
        'python-2.6.8-3.tar.bz2',
        'python-2.6.8-4.tar.bz2',
        'python-2.6.8-5.tar.bz2',
        'python-2.6.8-6.tar.bz2',
        'python-2.7.3-2.tar.bz2',
        'python-2.7.3-3.tar.bz2',
        'python-2.7.3-4.tar.bz2',
        'python-2.7.3-5.tar.bz2',
        'python-2.7.3-6.tar.bz2',
        'python-2.7.3-7.tar.bz2',
        'python-2.7.4-0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    }

    assert set(r.get_dists(['mypackage'], max_only=True).keys()) == {
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py26_0.tar.bz2',
        'nose-1.3.0-py27_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.6.8-6.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    }

    assert r.solve(['mypackage']) == r.solve(['mypackage 1.1']) == [
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]
    assert raises(NoPackagesFound, lambda: r.solve(['mypackage 1.0']))

    assert r.solve(['anotherpackage 1.0']) == [
        'anotherpackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]

    assert r.solve(['anotherpackage']) == [
        'anotherpackage-2.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]

    # This time, the latest version is messed up
    index3 = index.copy()
    index3['mypackage-1.1-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.1',
    }
    index3['mypackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'python 3.3*'],
        'name': 'mypackage',
        'requires': ['nose 1.2.1', 'python 3.3'],
        'version': '1.0',
    }
    index3['anotherpackage-1.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage 1.0'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage 1.0'],
        'version': '1.0',
    }
    index3['anotherpackage-2.0-py33_0.tar.bz2'] = {
        'build': 'py33_0',
        'build_number': 0,
        'depends': ['nose', 'mypackage'],
        'name': 'anotherpackage',
        'requires': ['nose', 'mypackage'],
        'version': '2.0',
    }
    r = Resolve(index3)

    assert set(r.find_matches(MatchSpec('mypackage'))) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'mypackage-1.1-py33_0.tar.bz2',
        }
    assert set(r.get_dists(['mypackage']).keys()) == {
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.1.2-py26_0.tar.bz2',
        'nose-1.1.2-py27_0.tar.bz2',
        'nose-1.1.2-py33_0.tar.bz2',
        'nose-1.2.1-py26_0.tar.bz2',
        'nose-1.2.1-py27_0.tar.bz2',
        'nose-1.2.1-py33_0.tar.bz2',
        'nose-1.3.0-py26_0.tar.bz2',
        'nose-1.3.0-py27_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-2.6.8-1.tar.bz2',
        'python-2.6.8-2.tar.bz2',
        'python-2.6.8-3.tar.bz2',
        'python-2.6.8-4.tar.bz2',
        'python-2.6.8-5.tar.bz2',
        'python-2.6.8-6.tar.bz2',
        'python-2.7.3-2.tar.bz2',
        'python-2.7.3-3.tar.bz2',
        'python-2.7.3-4.tar.bz2',
        'python-2.7.3-5.tar.bz2',
        'python-2.7.3-6.tar.bz2',
        'python-2.7.3-7.tar.bz2',
        'python-2.7.4-0.tar.bz2',
        'python-2.7.5-0.tar.bz2',
        'python-3.3.0-2.tar.bz2',
        'python-3.3.0-3.tar.bz2',
        'python-3.3.0-4.tar.bz2',
        'python-3.3.0-pro0.tar.bz2',
        'python-3.3.0-pro1.tar.bz2',
        'python-3.3.1-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    }

    assert raises(NoPackagesFound, lambda: r.get_dists(['mypackage'], max_only=True))

    assert r.solve(['mypackage']) == r.solve(['mypackage 1.0']) == [
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]
    assert raises(NoPackagesFound, lambda: r.solve(['mypackage 1.1']))


    assert r.solve(['anotherpackage 1.0']) == [
        'anotherpackage-1.0-py33_0.tar.bz2',
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]

    # If recursive checking is working correctly, this will give
    # anotherpackage 2.0, not anotherpackage 1.0
    assert r.solve(['anotherpackage']) == [
        'anotherpackage-2.0-py33_0.tar.bz2',
        'mypackage-1.0-py33_0.tar.bz2',
        'nose-1.3.0-py33_0.tar.bz2',
        'openssl-1.0.1c-0.tar.bz2',
        'python-3.3.2-0.tar.bz2',
        'readline-6.2-0.tar.bz2',
        'sqlite-3.7.13-0.tar.bz2',
        'system-5.8-1.tar.bz2',
        'tk-8.5.13-0.tar.bz2',
        'zlib-1.2.7-0.tar.bz2',
    ]