Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def test_no_features():
    # Features that aren't specified shouldn't be selected.
    r.msd_cache = {}

    # Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'.
    assert r.solve2(["python 2.6*", "numpy 1.6*", "scipy 0.11*"], set(), 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.solve2(["python 2.6*", "numpy 1.6*", "scipy 0.11*"], f_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.solve2(["pandas 0.12.0 np16py27_0", "python 2.7*"], set(), 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.solve2(["pandas 0.12.0 np16py27_0", "python 2.7*"], f_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]
    )
Exemplo n.º 4
0
def test_no_features():
    # Features that aren't specified shouldn't be selected.
    r.msd_cache = {}

    # Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'.
    assert r.solve2(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*'], set(),
        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.solve2(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*'], f_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.solve2(['pandas 0.12.0 np16py27_0', 'python 2.7*'], set(),
        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.solve2(['pandas 0.12.0 np16py27_0', 'python 2.7*'], f_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]
Exemplo n.º 5
0

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)


from conda.resolve import MatchSpec