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
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
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'])[0].keys()) == { 'package1-1.0-0.tar.bz2', 'package2-1.0-0.tar.bz2', } assert r.install(['package1']) == r.install(['package2']) == \ r.install(['package1', 'package2']) == [ 'package1-1.0-0.tar.bz2', 'package2-1.0-0.tar.bz2', ]
def resolve(info, verbose=False): if not index: sys.exit("Error: index is empty, maybe 'channels' are missing?") specs = info['specs'] r = Resolve(index) if not any(s.split()[0] == 'python' for s in specs): specs.append('python') if verbose: print("specs: %r" % specs) try: res = list(r.solve(specs)) except NoPackagesFound as e: sys.exit("Error: %s" % e) 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)
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': 'feature', 'version': '1.0', 'track_features': 'feature', } r = Resolve(index2) # It should not raise r.install(['mypackage', 'feature 1.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': 'feature', 'version': '1.0', 'track_features': 'feature', } r = Resolve(index2) # It should not raise r.install(['mypackage','feature 1.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) == [[ '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) == [[ '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]
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'])[0].keys()) == { 'mypackage-1.1-py33_0.tar.bz2', 'nose-1.1.2-py33_0.tar.bz2', 'nose-1.2.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-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 r.install(['mypackage']) == r.install(['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.install(['mypackage 1.0'])) assert raises(NoPackagesFound, lambda: r.install(['mypackage 1.0', 'burgertime 1.0'])) assert r.install(['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.install(['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'])[0].keys()) == { 'mypackage-1.0-py33_0.tar.bz2', 'nose-1.1.2-py33_0.tar.bz2', 'nose-1.2.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-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 r.install(['mypackage']) == r.install(['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.install(['mypackage 1.1'])) assert r.install(['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.install(['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', ]
from __future__ import print_function, absolute_import import json import unittest from os.path import dirname, join import pytest from libconda.resolve import MatchSpec, Package, Resolve, NoPackagesFound, Unsatisfiable, build_groups from tests.helpers import raises with open(join(dirname(__file__), 'index.json')) as fi: index = json.load(fi) r = Resolve(index) f_mkl = set(['mkl']) class TestMatchSpec(unittest.TestCase): def test_match(self): for spec, res in [ ('numpy 1.7*', True), ('numpy 1.7.1', True), ('numpy 1.7', False), ('numpy 1.5*', False), ('numpy >=1.5', True), ('numpy >=1.5,<2', True), ('numpy >=1.8,<1.9', False), ('numpy >1.5,<2,!=1.7.1', False), ('numpy >1.8,<2|==1.7', False), ('numpy >1.8,<2|>=1.7.1', True),
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) == [[ '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) == [[ '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]
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'])[0].keys()) == { 'mypackage-1.1-py33_0.tar.bz2', 'nose-1.1.2-py33_0.tar.bz2', 'nose-1.2.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-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 r.install(['mypackage']) == r.install(['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.install(['mypackage 1.0'])) assert raises(NoPackagesFound, lambda: r.install(['mypackage 1.0', 'burgertime 1.0'])) assert r.install(['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.install(['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'])[0].keys()) == { 'mypackage-1.0-py33_0.tar.bz2', 'nose-1.1.2-py33_0.tar.bz2', 'nose-1.2.1-py33_0.tar.bz2', 'nose-1.3.0-py33_0.tar.bz2', 'openssl-1.0.1c-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 r.install(['mypackage']) == r.install(['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.install(['mypackage 1.1'])) assert r.install(['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.install(['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', ]