Skip to content

Commit

Permalink
Add install actions list
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Dec 13, 2016
1 parent 7247368 commit 36aa101
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
6 changes: 3 additions & 3 deletions conda/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
PackageNotFoundError, TooManyArgumentsError, UnsatisfiableError)
from ..misc import append_env, clone_env, explicit, touch_nonadmin
from ..models.channel import prioritize_channels
from ..plan import (display_actions, execute_actions, get_pinned_specs, install_actions,
is_root_prefix, nothing_to_do, revert_actions)
from ..plan import (display_actions, execute_actions, get_pinned_specs,
is_root_prefix, nothing_to_do, revert_actions, install_actions_list)
from ..resolve import Resolve

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -275,7 +275,7 @@ def install(args, parser, command='install'):
else:
with common.json_progress_bars(json=context.json and not context.quiet):
_channel_priority_map = prioritize_channels(index_args['channel_urls'])
action_set = install_actions(
action_set = install_actions_list(
prefix, index, specs, force=args.force, only_names=only_names,
pinned=args.pinned, always_copy=context.always_copy,
minimal_hint=args.alt_hint, update_deps=context.update_dependencies,
Expand Down
26 changes: 26 additions & 0 deletions conda/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,32 @@ def install_actions(prefix, index, specs, force=False, only_names=None, always_c
pinned=True, minimal_hint=False, update_deps=True, prune=False,
channel_priority_map=None, is_update=False):
# type: (str, Dict[Dist, Record], List[str], bool, Option[List[str]], bool, bool, bool,
# bool, bool, bool, Dict[str, Sequence[str, int]]) -> Dict[weird]
specs = [MatchSpec(spec) for spec in specs]
r = get_resolve_object(index.copy(), prefix)

linked_in_root = linked_data(context.root_prefix)

dists_for_envs = determine_all_envs(r, specs, channel_priority_map=channel_priority_map)
ensure_packge_not_duplicated_in_private_env_root(dists_for_envs, linked_in_root)
preferred_envs = set(d.env for d in dists_for_envs)

assert len(preferred_envs) == 1
preferred_env = preferred_envs.pop()
specs_for_prefix = SpecsForPrefix(
prefix=preferred_env_to_prefix(preferred_env, context.root_dir, context.envs_dirs),
specs=tuple(sp.spec for sp in dists_for_envs),
r=r
)
actions = get_actions_for_dists(specs_for_prefix, only_names, index, force, always_copy, prune,
update_deps, pinned)
return actions


def install_actions_list(prefix, index, specs, force=False, only_names=None, always_copy=False,
pinned=True, minimal_hint=False, update_deps=True, prune=False,
channel_priority_map=None, is_update=False):
# type: (str, Dict[Dist, Record], List[str], bool, Option[List[str]], bool, bool, bool,
# bool, bool, bool, Dict[str, Sequence[str, int]]) -> List[Dict[weird]]
str_specs = specs
specs = [MatchSpec(spec) for spec in specs]
Expand Down
2 changes: 1 addition & 1 deletion conda_env/installers/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def install(prefix, specs, args, env, prune=False):
prepend='nodefaults' not in env.channels,
prefix=prefix)
_channel_priority_map = prioritize_channels(channel_urls)
action_set = plan.install_actions(prefix, index, specs, prune=prune,
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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_install_prune(self):
# 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(prefix,
actions_set = plan.install_actions_list(prefix,
index,
specs=['flask'],
prune=True)
Expand Down

0 comments on commit 36aa101

Please sign in to comment.