Exemple #1
0
def execute(args, parser):
    import sys
    import json
    from os.path import isfile

    from conda.builder.share import clone_bundle


    common.ensure_name_or_prefix(args, 'clone')

    prefix = common.get_prefix(args)

    path = args.path[0]
    if not isfile(path):
        sys.exit("Error: no such file: %s" % path)

    warnings = []
    for w in clone_bundle(path, prefix):
        if args.json:
            warnings.append(w)
        else:
            print "Warning:", w

    if args.json:
        json.dump(dict(warnings=warnings), sys.stdout, indent=2)
Exemple #2
0
def execute(args, parser):
    import sys
    from os.path import exists

    import conda.plan as plan
    from conda.api import get_index


    if len(args.package_specs) == 0 and not args.file:
        sys.exit('Error: too few arguments, must supply command line '
                 'package specs or --file')

    common.ensure_name_or_prefix(args, 'create')
    prefix = common.get_prefix(args)

    if exists(prefix):
        if args.prefix:
            raise RuntimeError("'%s' already exists, must supply new "
                               "directory for -p/--prefix" % prefix)
        else:
            raise RuntimeError("'%s' already exists, must supply new "
                               "directory for -n/--name" % prefix)

    if args.file:
        specs = common.specs_from_file(args.file)
    else:
        specs = common.specs_from_args(args.package_specs)

    common.check_specs(prefix, specs)

    channel_urls = args.channel or ()

    common.ensure_override_channels_requires_channel(args)
    index = get_index(channel_urls=channel_urls, prepend=not args.override_channels)
    actions = plan.install_actions(prefix, index, specs)

    if plan.nothing_to_do(actions):
        print 'No matching packages could be found, nothing to do'
        return

    print
    print "Package plan for creating environment at %s:" % prefix
    plan.display_actions(actions, index)

    common.confirm_yn(args)
    plan.execute_actions(actions, index, verbose=not args.quiet)

    if sys.platform != 'win32':
        activate_name = prefix
        if args.name:
            activate_name = args.name
        print "#"
        print "# To activate this environment, use:"
        print "# $ source activate %s" % activate_name
        print "#"
        print "# To deactivate this environment, use:"
        print "# $ source deactivate"
        print "#"