コード例 #1
0
ファイル: conda.py プロジェクト: conda/conda
def install(prefix, specs, args, env, prune=False):
    # TODO: support all various ways this happens
    # Including 'nodefaults' in the channels list disables the defaults
    new_specs = []
    channel_urls = set()
    for elem in specs:
        if "::" in elem:
            channel_urls.add(elem.split("::")[0])
            new_specs.append(elem.split("::")[-1])
        else:
            new_specs.append(elem)
    specs = new_specs
    channel_urls = list(channel_urls)
    # TODO: support all various ways this happens
    # Including 'nodefaults' in the channels list disables the defaults
    channel_urls = channel_urls + [chan for chan in env.channels if chan != "nodefaults"]
    index = get_index(channel_urls=channel_urls, prepend="nodefaults" not in env.channels, prefix=prefix)
    _channel_priority_map = prioritize_channels(channel_urls)
    action_set = plan.install_actions_list(
        prefix, index, specs, prune=prune, channel_priority_map=_channel_priority_map
    )

    with common.json_progress_bars(json=args.json and not args.quiet):
        for actions in action_set:
            try:
                plan.execute_actions(actions, index, verbose=not args.quiet)
            except RuntimeError as e:
                if len(e.args) > 0 and "LOCKERROR" in e.args[0]:
                    raise LockError("Already locked: %s" % text_type(e))
                else:
                    raise CondaRuntimeError("RuntimeError: %s" % e)
            except SystemExit as e:
                raise CondaSystemExit("Exiting", e)
コード例 #2
0
ファイル: test_create.py プロジェクト: mdbconsulting/conda
    def test_install_prune(self):
        with make_temp_env("python=2 decorator") as prefix:
            assert_package_is_installed(prefix, 'decorator')

            # prune is a feature used by conda-env
            # conda itself does not provide a public API for it
            index = get_index_trap(prefix=prefix)
            actions_set = plan.install_actions_list(prefix,
                                           index,
                                           specs=['flask'],
                                           prune=True)
            for actions in actions_set:
                plan.execute_actions(actions, index, verbose=True)

            assert_package_is_installed(prefix, 'flask')
            assert not package_is_installed(prefix, 'decorator')
コード例 #3
0
ファイル: test_create.py プロジェクト: ESSS/conda
    def test_install_prune(self):
        with make_temp_env("python=2 decorator") as prefix:
            assert_package_is_installed(prefix, 'decorator')

            # prune is a feature used by conda-env
            # conda itself does not provide a public API for it
            index = get_index_trap(prefix=prefix)
            actions_set = plan.install_actions_list(prefix,
                                           index,
                                           specs=['flask'],
                                           prune=True)
            for actions in actions_set:
                plan.execute_actions(actions, index, verbose=True)

            assert_package_is_installed(prefix, 'flask')
            assert not package_is_installed(prefix, 'decorator')
コード例 #4
0
def install(prefix, specs, args, env, prune=False):
    # TODO: support all various ways this happens
    # Including 'nodefaults' in the channels list disables the defaults
    new_specs = []
    channel_urls = set()
    for elem in specs:
        if "::" in elem:
            channel_urls.add(elem.split("::")[0])
            new_specs.append(elem.split("::")[-1])
        else:
            new_specs.append(elem)
    specs = new_specs
    channel_urls = list(channel_urls)
    # TODO: support all various ways this happens
    # Including 'nodefaults' in the channels list disables the defaults
    channel_urls = channel_urls + [
        chan for chan in env.channels if chan != 'nodefaults'
    ]
    index = get_index(channel_urls=channel_urls,
                      prepend='nodefaults' not in env.channels,
                      prefix=prefix)
    _channel_priority_map = prioritize_channels(channel_urls)
    action_set = plan.install_actions_list(
        prefix,
        index,
        specs,
        prune=prune,
        channel_priority_map=_channel_priority_map)

    with common.json_progress_bars(json=args.json and not args.quiet):
        for actions in action_set:
            try:
                plan.execute_actions(actions, index, verbose=not args.quiet)
            except RuntimeError as e:
                if len(e.args) > 0 and "LOCKERROR" in e.args[0]:
                    raise LockError('Already locked: %s' % text_type(e))
                else:
                    raise CondaHTTPError('CondaHTTPError: %s' % e)
            except SystemExit as e:
                raise CondaSystemExit('Exiting', e)