Example #1
0
def clone(src_arg, dst_prefix, json=False, quiet=False):
    from conda.misc import clone_env

    if os.sep in src_arg:
        src_prefix = abspath(src_arg)
        if not isdir(src_prefix):
            common.error_and_exit('no such directory: %s' % src_arg,
                                  json=json,
                                  error_type="NoEnvironmentFound")
    else:
        src_prefix = common.find_prefix_name(src_arg)
        if src_prefix is None:
            common.error_and_exit('could not find environment: %s' % src_arg,
                                  json=json,
                                  error_type="NoEnvironmentFound")

    if not json:
        print("src_prefix: %r" % src_prefix)
        print("dst_prefix: %r" % dst_prefix)

    with common.json_progress_bars(json=json and not quiet):
        actions, untracked_files = clone_env(src_prefix,
                                             dst_prefix,
                                             verbose=not json,
                                             quiet=quiet)

    if json:
        common.stdout_json_success(actions=actions,
                                   untracked_files=list(untracked_files),
                                   src_prefix=src_prefix,
                                   dst_prefix=dst_prefix)
Example #2
0
def clone(src_arg, dst_prefix, json=False, quiet=False, index=None):
    if os.sep in src_arg:
        src_prefix = abspath(src_arg)
        if not isdir(src_prefix):
            common.error_and_exit('no such directory: %s' % src_arg,
                                  json=json,
                                  error_type="NoEnvironmentFound")
    else:
        src_prefix = common.find_prefix_name(src_arg)
        if src_prefix is None:
            common.error_and_exit('could not find environment: %s' % src_arg,
                                  json=json,
                                  error_type="NoEnvironmentFound")

    if not json:
        print("src_prefix: %r" % src_prefix)
        print("dst_prefix: %r" % dst_prefix)

    with common.json_progress_bars(json=json and not quiet):
        actions, untracked_files = misc.clone_env(src_prefix, dst_prefix,
                                                  verbose=not json,
                                                  quiet=quiet, index=index)

    if json:
        common.stdout_json_success(
            actions=actions,
            untracked_files=list(untracked_files),
            src_prefix=src_prefix,
            dst_prefix=dst_prefix
        )
Example #3
0
def prefix_from_arg(arg):
    if os.sep in arg:
        return abspath(arg)
    prefix = find_prefix_name(arg)
    if prefix is None:
        sys.exit('Error: could not find environment: %s' % arg)
    return prefix
Example #4
0
def prefix_from_arg(arg):
    if os.sep in arg:
        return arg
    prefix = find_prefix_name(arg)
    if prefix is None:
        sys.exit('Error: could not find environment: %s' % arg)
    return prefix
Example #5
0
def prefix_from_arg(arg):
    if os.sep in arg:
        if isdir(abspath(arg.strip("\""))):
            prefix = abspath(arg.strip("\""))
        else:
            sys.exit('Error: could not find environment: %s' % arg)
    else:
        prefix = find_prefix_name(arg)
        if prefix is None:
            sys.exit('Error: could not find environment: %s' % arg)
    return prefix
Example #6
0
def prefix_from_arg(arg):
    if os.sep in arg:
        if isdir(abspath(arg.strip("\""))):
            prefix = abspath(arg.strip("\""))
        else:
            sys.exit('Error: could not find environment: %s' % arg)
    else:
        prefix = find_prefix_name(arg)
        if prefix is None:
            sys.exit('Error: could not find environment: %s' % arg)
    return prefix
Example #7
0
def prefix_from_arg(arg, shelldict):
    if shelldict['sep'] in arg:
        # strip is removing " marks, not \ - look carefully
        native_path = shelldict['path_from'](arg)
        if isdir(abspath(native_path.strip("\""))):
            prefix = abspath(native_path.strip("\""))
        else:
            raise ValueError('could not find environment: %s' % native_path)
    else:
        prefix = find_prefix_name(arg)
        if prefix is None:
            raise ValueError('could not find environment: %s' % arg)
    return shelldict['path_to'](prefix)
Example #8
0
def prefix_from_arg(arg, shelldict):
    if shelldict['sep'] in arg:
        # strip is removing " marks, not \ - look carefully
        native_path = shelldict['path_from'](arg)
        if isdir(abspath(native_path.strip("\""))):
            prefix = abspath(native_path.strip("\""))
        else:
            raise ValueError('could not find environment: %s' % native_path)
    else:
        prefix = find_prefix_name(arg)
        if prefix is None:
            raise ValueError('could not find environment: %s' % arg)
    return shelldict['path_to'](prefix)
Example #9
0
def clone(src_arg, dst_prefix):
    from conda.misc import clone_env

    if os.sep in src_arg:
        src_prefix = abspath(src_arg)
        if not isdir(src_prefix):
            sys.exit('Error: could such directory: %s' % src_arg)
    else:
        src_prefix = common.find_prefix_name(src_arg)
        if src_prefix is None:
            sys.exit('Error: could not find environment: %s' % src_arg)

    print("src_prefix: %r" % src_prefix)
    print("dst_prefix: %r" % dst_prefix)
    clone_env(src_prefix, dst_prefix)
Example #10
0
def clone(src_arg, dst_prefix):
    from conda.misc import clone_env

    if os.sep in src_arg:
        src_prefix = abspath(src_arg)
        if not isdir(src_prefix):
            sys.exit('Error: could such directory: %s' % src_arg)
    else:
        src_prefix = common.find_prefix_name(src_arg)
        if src_prefix is None:
            sys.exit('Error: could not find environment: %s' % src_arg)

    print("src_prefix: %r" % src_prefix)
    print("dst_prefix: %r" % dst_prefix)
    clone_env(src_prefix, dst_prefix)
Example #11
0
def prefix_from_arg(arg, shelldict):
    'Returns a platform-native path'
    # MSYS2 converts Unix paths to Windows paths with unix seps
    # so we must check for the drive identifier too.
    if shelldict['sep'] in arg and not re.match('[a-zA-Z]:', arg):
        # strip is removing " marks, not \ - look carefully
        native_path = shelldict['path_from'](arg)
        if isdir(abspath(native_path.strip("\""))):
            prefix = abspath(native_path.strip("\""))
        else:
            raise ValueError('could not find environment: %s' % native_path)
    else:
        prefix = find_prefix_name(arg.replace('/', os.path.sep))
        if prefix is None:
            raise ValueError('could not find environment: %s' % arg)
    return prefix
Example #12
0
def prefix_from_arg(arg, shelldict):
    'Returns a platform-native path'
    # MSYS2 converts Unix paths to Windows paths with unix seps
    # so we must check for the drive identifier too.
    if shelldict['sep'] in arg and not re.match('[a-zA-Z]:', arg):
        # strip is removing " marks, not \ - look carefully
        native_path = shelldict['path_from'](arg)
        if isdir(abspath(native_path.strip("\""))):
            prefix = abspath(native_path.strip("\""))
        else:
            raise ValueError('could not find environment: %s' % native_path)
    else:
        prefix = find_prefix_name(arg.replace('/', os.path.sep))
        if prefix is None:
            raise ValueError('could not find environment: %s' % arg)
    return prefix
Example #13
0
def execute(args, parser):
    import os
    import sys
    from os.path import abspath, exists, isfile

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

    common.ensure_name_or_prefix(args, "create")
    prefix = common.get_prefix(args, search=False)
    if exists(prefix):
        sys.exit("Error: prefix already exists: %s" % prefix)

    if args.clone:
        path = abspath(args.clone)
        if isfile(path):
            from conda.builder.share import clone_bundle

            clone_bundle(path, prefix)
            return
        else:
            from conda.misc import clone_env

            if os.sep in args.clone:
                src_prefix = path
            else:
                src_prefix = common.find_prefix_name(args.clone)
            print("src_prefix: %r" % src_prefix)
            if src_prefix is None:
                sys.exit("Error: could not find environment: %s" % args.clone)
            clone_env(src_prefix, prefix)
            args.yes = True
    else:
        if len(args.package_specs) == 0 and not args.file:
            sys.exit("Error: too few arguments, must supply command line " "package specs or --file")

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

    if args.clone and len(specs) == 0:
        return
    else:
        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)

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