How to use the conda.resolve.MatchSpec function in conda

To help you get started, we’ve selected a few conda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conda / conda / tests / core / test_solve.py View on Github external
'channel-1::sqlite-3.7.13-0',
                'channel-1::system-5.8-1',
                'channel-1::tk-8.5.13-0',
                'channel-1::zlib-1.2.7-0',
                'channel-1::llvm-3.2-0',
                'channel-1::python-2.6.8-6',
                'channel-1::argparse-1.2.1-py26_0',
                'channel-1::llvmpy-0.11.2-py26_0',
                'channel-1::numpy-1.7.1-py26_0',
                'channel-1::numba-0.8.1-np17py26_0',
            ))
            assert convert_to_dist_str(final_state_5) == order

    # now update without pinning
    specs_to_add = MatchSpec("python"),
    history_specs = MatchSpec("python"), MatchSpec("system=5.8=0"), MatchSpec("numba"),
    with get_solver(specs_to_add=specs_to_add, prefix_records=final_state_4,
                    history_specs=history_specs) as solver:
        final_state_5 = solver.solve_final_state(update_modifier=UpdateModifier.UPDATE_ALL)
        # PrefixDag(final_state_1, specs).open_url()
        print(convert_to_dist_str(final_state_5))
        order = add_subdir_to_iter((
            'channel-1::openssl-1.0.1c-0',
            'channel-1::readline-6.2-0',
            'channel-1::sqlite-3.7.13-0',
            'channel-1::system-5.8-1',
            'channel-1::tk-8.5.13-0',
            'channel-1::zlib-1.2.7-0',
            'channel-1::llvm-3.2-0',
            'channel-1::python-3.3.2-0',
            'channel-1::llvmpy-0.11.2-py33_0',
            'channel-1::numpy-1.7.1-py33_0',
github conda / conda / tests / core / test_solve.py View on Github external
'channel-1::zlib-1.2.7-0',
            'channel-1::python-2.7.5-0',
            'channel-1::jinja2-2.6-py27_0',
            'channel-1::pytz-2013b-py27_0',
            'channel-1::scipy-0.12.0-np16py27_0',
            'channel-1::six-1.3.0-py27_0',
            'channel-1::werkzeug-0.8.3-py27_0',
            'channel-1::dateutil-2.1-py27_1',
            'channel-1::flask-0.9-py27_0',
            'channel-1::pandas-0.11.0-np16py27_1'
        ))
        assert convert_to_dist_str(final_state_2) == order
        assert not solver._r.environment_is_consistent(final_state_2)

    # adding numpy spec again snaps the packages back to a consistent state
    specs_to_add = MatchSpec("flask"), MatchSpec("numpy 1.6.*"),
    with get_solver(specs_to_add, prefix_records=final_state_1_modified, history_specs=specs) as solver:
        final_state_2 = solver.solve_final_state()
        # PrefixDag(final_state_2, specs).open_url()
        print(convert_to_dist_str(final_state_2))
        order = add_subdir_to_iter((
            'channel-1::openssl-1.0.1c-0',
            'channel-1::readline-6.2-0',
            'channel-1::sqlite-3.7.13-0',
            'channel-1::system-5.8-1',
            'channel-1::tk-8.5.13-0',
            'channel-1::zlib-1.2.7-0',
            'channel-1::python-2.7.5-0',
            'channel-1::jinja2-2.6-py27_0',
            'channel-1::numpy-1.6.2-py27_4',
            'channel-1::pytz-2013b-py27_0',
            'channel-1::six-1.3.0-py27_0',
github conda / conda / tests / core / test_solve.py View on Github external
def test_update_all_1():
    specs = MatchSpec("numpy=1.5"), MatchSpec("python=2.6"), MatchSpec("system[build_number=0]")
    with get_solver(specs) as solver:
        final_state_1 = solver.solve_final_state()
        # PrefixDag(final_state_1, specs).open_url()
        print(convert_to_dist_str(final_state_1))
        order = add_subdir_to_iter((
            'channel-1::openssl-1.0.1c-0',
            'channel-1::readline-6.2-0',
            'channel-1::sqlite-3.7.13-0',
            'channel-1::system-5.8-0',
            'channel-1::tk-8.5.13-0',
            'channel-1::zlib-1.2.7-0',
            'channel-1::python-2.6.8-6',
            'channel-1::numpy-1.5.1-py26_4',
        ))
        assert convert_to_dist_str(final_state_1) == order
github conda / conda / tests / core / test_solve.py View on Github external
def test_solve_2():
    specs = MatchSpec("numpy"),

    with get_solver_aggregate_1(specs) as solver:
        final_state = solver.solve_final_state()
        # print(convert_to_dist_str(final_state))
        order = add_subdir_to_iter((
            'channel-2::mkl-2017.0.3-0',
            'channel-2::openssl-1.0.2l-0',
            'channel-2::readline-6.2-2',
            'channel-2::sqlite-3.13.0-0',
            'channel-2::tk-8.5.18-0',
            'channel-2::xz-5.2.3-0',
            'channel-2::zlib-1.2.11-0',
            'channel-2::python-3.6.2-0',
            'channel-2::numpy-1.13.1-py36_0'
        ))
        assert convert_to_dist_str(final_state) == order
github conda / conda / tests / core / test_solve.py View on Github external
'channel-1::system-5.8-1',
            'channel-1::tk-8.5.13-0',
            'channel-1::zlib-1.2.7-0',
            'channel-1::python-2.7.5-0',
            'channel-1::nose-1.3.0-py27_0',
            'channel-1::zope.interface-4.0.5-py27_0',
        ))
        assert convert_to_dist_str(final_state_2) == order

    specs_to_add = MatchSpec("zope.interface>4.1"),
    with get_solver(specs_to_add, prefix_records=final_state_1, history_specs=specs) as solver:
        with pytest.raises(UnsatisfiableError):
            final_state_2 = solver.solve_final_state()

    # allow python to float
    specs_to_add = MatchSpec("zope.interface>4.1"), MatchSpec("python")
    with get_solver(specs_to_add, prefix_records=final_state_1, history_specs=specs) as solver:
        final_state_2 = solver.solve_final_state()
        # PrefixDag(final_state_2, specs).open_url()
        print(convert_to_dist_str(final_state_2))
        order = add_subdir_to_iter((
            'channel-1::openssl-1.0.1c-0',
            'channel-1::readline-6.2-0',
            'channel-1::sqlite-3.7.13-0',
            'channel-1::system-5.8-1',
            'channel-1::tk-8.5.13-0',
            'channel-1::zlib-1.2.7-0',
            'channel-1::python-3.3.2-0',
            'channel-1::nose-1.3.0-py33_0',
            'channel-1::zope.interface-4.1.1.1-py33_0',
        ))
        assert convert_to_dist_str(final_state_2) == order
github conda / conda / conda / builder / metadata.py View on Github external
def ms_depends(self, typ='run'):
        res = []
        for spec in self.get_value('requirements/' + typ):
            try:
                ms = MatchSpec(spec)
            except AssertionError:
                raise RuntimeError("Invalid package specification: %r" % spec)
            for name, ver in [('python', CONDA_PY), ('numpy', CONDA_NPY)]:
                if ms.name == name:
                    if ms.strictness != 1:
                        sys.exit("""Error:
    You cannot specify a version for package '%s' in the requirements.
    Please use the environment variables CONDA_PY or CONDA_NPY.
""" % name)
                    ms = MatchSpec('%s %s*' % (name, '.'.join(str(ver))))
            res.append(ms)
        return res
github conda / conda / conda / from_pypi.py View on Github external
def install_with_pip(prefix, index, specs):
    r = Resolve(index)
    for_conda = []

    try:
        next(r.find_matches(MatchSpec('pip')))
    except StopIteration:
        print("Pip not found, running `conda install pip` ...")
        try:
            install_package(prefix, 'pip')
        except Exception as e:
            print("Could not install pip --- continuing...")
            return specs

    for s in specs:
        try:
            next(r.find_matches(MatchSpec(s)))
        except StopIteration:
            if s == 'pip':
                for_conda.append(s)
                continue
            print("Conda package not available for %s, attempting to install "
github conda / conda / conda / share.py View on Github external
def update_info(info):
    h = hashlib.new('sha1')
    for spec in info['depends']:
        assert MatchSpec(spec).strictness == 3
        h.update(spec.encode('utf-8'))
        h.update(b'\x00')
    h.update(info['file_hash'].encode('utf-8'))
    info['version'] = h.hexdigest()
github conda / conda / conda / plan.py View on Github external
# Get conda-meta/pinned
    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s", pinned_specs)
        specs.extend(pinned_specs)

    # Support aggressive auto-update conda
    #   Only add a conda spec if conda and conda-env are not in the specs.
    #   Also skip this step if we're offline.
    root_only_specs_str = ('conda', 'conda-env')
    conda_in_specs_str = any(spec for spec in specs if spec.name in root_only_specs_str)

    if is_root_prefix(prefix):
        if context.auto_update_conda and not context.offline and not conda_in_specs_str:
            specs.append(MatchSpec('conda'))
            specs.append(MatchSpec('conda-env'))
    elif basename(prefix).startswith('_'):
        # Anything (including conda) can be installed into environments
        # starting with '_', mainly to allow conda-build to build conda
        pass
    elif conda_in_specs_str:
        raise InstallError("Error: 'conda' can only be installed into the "
                           "root environment")

    # Support track_features config parameter
    if context.track_features:
        specs.extend(x + '@' for x in context.track_features)

    return list(specs)
github conda / conda / conda / plan.py View on Github external
# Get conda-meta/pinned
    if pinned:
        pinned_specs = get_pinned_specs(prefix)
        log.debug("Pinned specs=%s", pinned_specs)
        specs.extend(pinned_specs)

    # Support aggressive auto-update conda
    #   Only add a conda spec if conda and conda-env are not in the specs.
    #   Also skip this step if we're offline.
    root_only_specs_str = ('conda', 'conda-env')
    conda_in_specs_str = any(spec for spec in specs if spec.name in root_only_specs_str)

    if is_root_prefix(prefix):
        if context.auto_update_conda and not context.offline and not conda_in_specs_str:
            specs.append(MatchSpec('conda'))
            specs.append(MatchSpec('conda-env'))
    elif basename(prefix).startswith('_'):
        # Anything (including conda) can be installed into environments
        # starting with '_', mainly to allow conda-build to build conda
        pass
    elif conda_in_specs_str:
        raise InstallError("Error: 'conda' can only be installed into the "
                           "root environment")

    # Support track_features config parameter
    if context.track_features:
        specs.extend(x + '@' for x in context.track_features)

    return list(specs)