Exemplo n.º 1
0
def execute(args, parser):
    from conda import config
    from conda.api import get_package_versions, app_is_installed
    from conda.install import is_linked

    if args.args:
        results = defaultdict(list)

        for arg in args.args:
            if isfile(arg):
                from conda.misc import which_package
                path = arg
                for dist in which_package(path):
                    if args.json:
                        results[arg].append(dist)
                    else:
                        print('%-50s  %s' % (path, dist))
            elif arg.endswith('.tar.bz2'):
                info = is_linked(config.root_dir, arg[:-8])
                if not info:
                    if args.json:
                        results[arg] = {
                            'installed': []
                        }
                    else:
                        print("Package %s is not installed" % arg)

                    continue

                info['installed'] = app_is_installed(arg)
                if args.json:
                    results[arg] = info
                else:
                    print(arg)
                    print('    %-15s %30s' %
                               ('installed', bool(info.get('installed'))))

                    for key in ('name', 'version', 'build', 'license',
                                'platform', 'arch', 'size', 'summary'):
                        print('    %-15s %30s' % (key, info.get(key)))
            else:
                if args.json:
                    for pkg in get_package_versions(arg):
                        results[arg].append(pkg._asdict())
                else:
                    show_pkg_info(arg)

        if args.json:
            common.stdout_json(results)
        return

    import os
    from os.path import basename, dirname, isdir, join

    import conda
    import conda.config as config
    from conda.cli.main_init import is_initialized

    options = 'envs', 'system', 'license'

    info_dict = dict(platform=config.subdir,
                     conda_version=conda.__version__,
                     root_prefix=config.root_dir,
                     root_writable=config.root_writable,
                     pkgs_dirs=config.pkgs_dirs,
                     envs_dirs=config.envs_dirs,
                     default_prefix=config.default_prefix,
                     channels=config.get_channel_urls(),
                     rc_path=config.rc_path,
                     is_foreign=bool(config.foreign),
                     envs=[],
                     python_version='.'.join(map(str, sys.version_info)),
    )

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    t_pat = re.compile(r'binstar\.org/(t/[0-9a-f\-]{4,})')
    info_dict['channels_disp'] = [t_pat.sub('binstar.org/t/<TOKEN>', c)
                                  for c in info_dict['channels']]

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels_disp':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
       python version : %(python_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels_disp)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' uninitalized,
#     use 'conda init' to initialize.""" % config.root_dir)

    del info_dict['channels_disp']

    if args.envs:
        if not args.json:
            print("# conda environments:")
            print("#")
        def disp_env(prefix):
            fmt = '%-20s  %s  %s'
            default = '*' if prefix == config.default_prefix else ' '
            name = (config.root_env_name if prefix == config.root_dir else
                    basename(prefix))
            if not args.json:
                print(fmt % (name, default, prefix))

        for envs_dir in config.envs_dirs:
            if not isdir(envs_dir):
                continue
            for dn in sorted(os.listdir(envs_dir)):
                if dn.startswith('.'):
                    continue
                prefix = join(envs_dir, dn)
                if isdir(prefix):
                    prefix = join(envs_dir, dn)
                    disp_env(prefix)
                    info_dict['envs'].append(prefix)
        disp_env(config.root_dir)
        print()

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable(cmd)))
        print()

        evars = ['PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
                 'CIO_TEST', 'CONDA_ENVS_PATH']
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 2
0
def execute(args, parser):
    import os
    from os.path import basename, dirname

    import conda
    import conda.config as config
    import conda.misc as misc
    from conda.resolve import Resolve, MatchSpec
    from conda.cli.main_init import is_initialized
    from conda.api import get_index, get_package_versions

    if args.root:
        if args.json:
            common.stdout_json({'root_prefix': config.root_dir})
        else:
            print(config.root_dir)
        return

    if args.packages:
        if args.json:
            results = defaultdict(list)
            for arg in args.packages:
                for pkg in get_package_versions(arg):
                    results[arg].append(pkg._asdict())
            common.stdout_json(results)
            return
        index = get_index()
        r = Resolve(index)
        specs = map(common.arg2spec, args.packages)

        for spec in specs:
            versions = r.get_pkgs(MatchSpec(spec))
            for pkg in versions:
                pretty_package(pkg)

        return

    options = 'envs', 'system', 'license'

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    info_dict = dict(platform=config.subdir,
                     conda_version=conda.__version__,
                     conda_build_version=conda_build_version,
                     root_prefix=config.root_dir,
                     root_writable=config.root_writable,
                     pkgs_dirs=config.pkgs_dirs,
                     envs_dirs=config.envs_dirs,
                     default_prefix=config.default_prefix,
                     channels=config.get_channel_urls(),
                     rc_path=config.rc_path,
                     user_rc_path=config.user_rc_path,
                     sys_rc_path=config.sys_rc_path,
                     is_foreign=bool(config.foreign),
                     envs=[],
                     python_version='.'.join(map(str, sys.version_info)),
                     requests_version=requests_version,
    )

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    info_dict['channels'] = [config.hide_binstar_tokens(c) for c in
        info_dict['channels']]

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' is uninitialized""" % config.root_dir)

    if args.envs:
        common.handle_envs_list(info_dict['envs'], not args.json)

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
        print("user site dirs: ", end='')
        site_dirs = get_user_site()
        if site_dirs:
            print(site_dirs[0])
        else:
            print()
        for site_dir in site_dirs[1:]:
            print('                %s' % site_dir)
        print()

        evars = ['PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
                 'CIO_TEST', 'CONDA_ENVS_PATH']
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 3
0
def execute(args, parser):
    if args.base:
        if context.json:
            stdout_json({'root_prefix': context.root_prefix})
        else:
            print(context.root_prefix)
        return

    if args.packages:
        from ..resolve import ResolvePackageNotFound
        try:
            print_package_info(args.packages)
            return
        except ResolvePackageNotFound as e:  # pragma: no cover
            from ..exceptions import PackagesNotFoundError
            raise PackagesNotFoundError(e.bad_deps)

    if args.unsafe_channels:
        if not context.json:
            print("\n".join(context.channels))
        else:
            print(json.dumps({"channels": context.channels}))
        return 0

    options = 'envs', 'system', 'license'

    if args.all or context.json:
        for option in options:
            setattr(args, option, True)
    info_dict = get_info_dict(args.system)

    if (args.all or all(not getattr(args, opt) for opt in options)) and not context.json:
        print(get_main_info_str(info_dict))

    if args.envs:
        from ..core.envs_manager import list_all_known_prefixes
        info_dict['envs'] = list_all_known_prefixes()
        print_envs_list(info_dict['envs'], not context.json)

    if args.system:
        if not context.json:
            from .find_commands import find_commands, find_executable
            print("sys.version: %s..." % (sys.version[:40]))
            print("sys.prefix: %s" % sys.prefix)
            print("sys.executable: %s" % sys.executable)
            print("conda location: %s" % info_dict['conda_location'])
            for cmd in sorted(set(find_commands() + ('build',))):
                print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
            print("user site dirs: ", end='')
            site_dirs = info_dict['site_dirs']
            if site_dirs:
                print(site_dirs[0])
            else:
                print()
            for site_dir in site_dirs[1:]:
                print('                %s' % site_dir)
            print()

            for name, value in sorted(iteritems(info_dict['env_vars'])):
                print("%s: %s" % (name, value))
            print()

    if args.license and not context.json:
        try:
            from _license import show_info
            show_info()  # pragma: no cover
        except ImportError:
            print(dedent("""
                WARNING: could not import _license.show_info
                # try:
                # $ conda install -n root _license"""))
        except Exception as e:  # pragma: no cover
            log.warn('%r', e)

    if context.json:
        stdout_json(info_dict)
Exemplo n.º 4
0
def execute(args, parser):
    from ..base.context import context

    if args.root:
        if context.json:
            stdout_json({'root_prefix': context.root_prefix})
        else:
            print(context.root_prefix)
        return

    if args.packages:
        print_package_info(args.packages)
        return

    if args.unsafe_channels:
        if not context.json:
            print("\n".join(context.channels))
        else:
            print(json.dumps({"channels": context.channels}))
        return 0

    options = 'envs', 'system', 'license'

    if args.all or context.json:
        for option in options:
            setattr(args, option, True)

    info_dict = get_info_dict(args.system)

    if (args.all or all(not getattr(args, opt) for opt in options)) and not context.json:
        print(get_main_info_str(info_dict))

    if args.envs:
        handle_envs_list(info_dict['envs'], not context.json)

    if args.system:
        if not context.json:
            from .find_commands import find_commands, find_executable
            print("sys.version: %s..." % (sys.version[:40]))
            print("sys.prefix: %s" % sys.prefix)
            print("sys.executable: %s" % sys.executable)
            print("conda location: %s" % info_dict['conda_location'])
            for cmd in sorted(set(find_commands() + ['build'])):
                print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
            print("user site dirs: ", end='')
            site_dirs = get_user_site()
            if site_dirs:
                print(site_dirs[0])
            else:
                print()
            for site_dir in site_dirs[1:]:
                print('                %s' % site_dir)
            print()

            for name, value in sorted(iteritems(info_dict['env_vars'])):
                print("%s: %s" % (name, value))
            print()

    if args.license and not context.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if context.json:
        stdout_json(info_dict)
Exemplo n.º 5
0
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    from conda.config import (root_dir, get_channel_urls, subdir, pkgs_dirs,
                              root_writable, envs_dirs, default_prefix,
                              rc_path, user_rc_path, sys_rc_path, foreign,
                              hide_binstar_tokens, platform, offline)
    from conda.resolve import Resolve
    from conda.api import get_index

    if args.root:
        if args.json:
            stdout_json({'root_prefix': root_dir})
        else:
            print(root_dir)
        return

    if args.packages:
        index = get_index()
        r = Resolve(index)
        if args.json:
            stdout_json({
                package:
                [p._asdict() for p in sorted(r.get_pkgs(arg2spec(package)))]
                for package in args.packages
            })
        else:
            for package in args.packages:
                versions = r.get_pkgs(arg2spec(package))
                for pkg in sorted(versions):
                    pretty_package(pkg)
        return

    options = 'envs', 'system', 'license'

    try:
        from conda.install import linked_data
        root_pkgs = linked_data(sys.prefix)
    except:
        root_pkgs = None

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        cenv = [p for p in itervalues(root_pkgs) if p['name'] == 'conda-env']
        conda_env_version = cenv[0]['version']
    except:
        conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    channels = get_channel_urls(offline=offline)

    info_dict = dict(
        platform=subdir,
        conda_version=conda.__version__,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=root_dir,
        root_writable=root_writable,
        pkgs_dirs=pkgs_dirs,
        envs_dirs=envs_dirs,
        default_prefix=default_prefix,
        channels=channels,
        rc_path=rc_path,
        user_rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        is_foreign=bool(foreign),
        offline=offline,
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
    )

    if args.unsafe_channels:
        if not args.json:
            print("\n".join(info_dict["channels"]))
        else:
            print(json.dumps({"channels": info_dict["channels"]}))
        return 0
    else:
        info_dict['channels'] = [
            hide_binstar_tokens(c) for c in info_dict['channels']
        ]
    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable'
                               if info_dict['root_writable'] else 'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
    conda-env version : %(conda_env_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
         offline mode : %(offline)s
    is foreign system : %(is_foreign)s
""" % info_dict)

    if args.envs:
        handle_envs_list(info_dict['envs'], not args.json)

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
        print("user site dirs: ", end='')
        site_dirs = get_user_site()
        if site_dirs:
            print(site_dirs[0])
        else:
            print()
        for site_dir in site_dirs[1:]:
            print('                %s' % site_dir)
        print()

        evars = [
            'PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
            'CIO_TEST', 'CONDA_ENVS_PATH'
        ]
        if platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        stdout_json(info_dict)
Exemplo n.º 6
0
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    from conda.config import (root_dir, get_channel_urls, subdir, pkgs_dirs,
                              root_writable, envs_dirs, default_prefix, rc_path,
                              user_rc_path, sys_rc_path, foreign, hide_binstar_tokens,
                              platform, offline)
    from conda.resolve import Resolve
    from conda.api import get_index

    if args.root:
        if args.json:
            stdout_json({'root_prefix': root_dir})
        else:
            print(root_dir)
        return

    if args.packages:
        index = get_index()
        r = Resolve(index)
        if args.json:
            stdout_json({
                package: [p._asdict()
                          for p in sorted(r.get_pkgs(arg2spec(package)))]
                for package in args.packages
            })
        else:
            for package in args.packages:
                versions = r.get_pkgs(arg2spec(package))
                for pkg in sorted(versions):
                    pretty_package(pkg)
        return

    options = 'envs', 'system', 'license'

    try:
        from conda.install import linked_data
        root_pkgs = linked_data(sys.prefix)
    except:
        root_pkgs = None

    try:
        from .._vendor.requests import __version__ as requests_version
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        cenv = [p for p in itervalues(root_pkgs) if p['name'] == 'conda-env']
        conda_env_version = cenv[0]['version']
    except:
        conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    channels = get_channel_urls(offline=offline)

    info_dict = dict(
        platform=subdir,
        conda_version=conda.__version__,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=root_dir,
        root_writable=root_writable,
        pkgs_dirs=pkgs_dirs,
        envs_dirs=envs_dirs,
        default_prefix=default_prefix,
        channels=channels,
        rc_path=rc_path,
        user_rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        is_foreign=bool(foreign),
        offline=offline,
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
    )

    if args.unsafe_channels:
        if not args.json:
            print("\n".join(info_dict["channels"]))
        else:
            print(json.dumps({"channels": info_dict["channels"]}))
        return 0
    else:
        info_dict['channels'] = [hide_binstar_tokens(c) for c in
                                 info_dict['channels']]
    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
    conda-env version : %(conda_env_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
         offline mode : %(offline)s
    is foreign system : %(is_foreign)s
""" % info_dict)

    if args.envs:
        handle_envs_list(info_dict['envs'], not args.json)

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
        print("user site dirs: ", end='')
        site_dirs = get_user_site()
        if site_dirs:
            print(site_dirs[0])
        else:
            print()
        for site_dir in site_dirs[1:]:
            print('                %s' % site_dir)
        print()

        evars = ['PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
                 'CIO_TEST', 'CONDA_ENVS_PATH']
        if platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        stdout_json(info_dict)
Exemplo n.º 7
0
def execute(args, parser):
    import os
    from os.path import basename, dirname

    import conda
    import conda.config as config
    import conda.misc as misc
    from conda.resolve import Resolve, MatchSpec
    from conda.cli.main_init import is_initialized
    from conda.api import get_index, get_package_versions

    if args.packages:
        if args.json:
            results = defaultdict(list)
            for arg in args.packages:
                for pkg in get_package_versions(arg):
                    results[arg].append(pkg._asdict())
            common.stdout_json(results)
            return
        index = get_index()
        r = Resolve(index)
        specs = map(common.arg2spec, args.packages)

        for spec in specs:
            versions = r.get_pkgs(MatchSpec(spec))
            for pkg in versions:
                pretty_package(pkg)

        return

    options = 'envs', 'system', 'license'

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    info_dict = dict(
        platform=config.subdir,
        conda_version=conda.__version__,
        conda_build_version=conda_build_version,
        root_prefix=config.root_dir,
        root_writable=config.root_writable,
        pkgs_dirs=config.pkgs_dirs,
        envs_dirs=config.envs_dirs,
        default_prefix=config.default_prefix,
        channels=config.get_channel_urls(),
        rc_path=config.rc_path,
        is_foreign=bool(config.foreign),
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
    )

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    info_dict['channels_disp'] = [
        config.hide_binstar_tokens(c) for c in info_dict['channels']
    ]

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels_disp':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable'
                               if info_dict['root_writable'] else 'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels_disp)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' is uninitialized""" % config.root_dir)

    del info_dict['channels_disp']

    if args.envs:
        if not args.json:
            print("# conda environments:")
            print("#")

        def disp_env(prefix):
            fmt = '%-20s  %s  %s'
            default = '*' if prefix == config.default_prefix else ' '
            name = (config.root_env_name
                    if prefix == config.root_dir else basename(prefix))
            if not args.json:
                print(fmt % (name, default, prefix))

        for prefix in misc.list_prefixes():
            disp_env(prefix)
            if prefix != config.root_dir:
                info_dict['envs'].append(prefix)

        print()

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
        print("user site dirs: ", end='')
        site_dirs = get_user_site()
        if site_dirs:
            print(site_dirs[0])
        else:
            print()
        for site_dir in site_dirs[1:]:
            print('                %s' % site_dir)
        print()

        evars = [
            'PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
            'CIO_TEST', 'CONDA_ENVS_PATH'
        ]
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 8
0
def execute(args, parser):
    import os
    from os.path import basename, dirname, isdir, join

    import conda
    import conda.config as config
    from conda.cli.main_init import is_initialized

    options = 'envs', 'system', 'license'

    info_dict = dict(platform=config.subdir,
                     conda_version=conda.__version__,
                     root_prefix=config.root_dir,
                     root_writable=config.root_writable,
                     pkgs_dirs=config.pkgs_dirs,
                     envs_dirs=config.envs_dirs,
                     default_prefix=config.default_prefix,
                     channels=config.get_channel_urls(),
                     rc_path=config.rc_path,
                     envs=[])

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' uninitalized,
#     use 'conda init' to initialize.""" % config.root_dir)

    if args.envs:
        if not args.json:
            print("# conda environments:")
            print("#")
        def disp_env(prefix):
            fmt = '%-20s  %s  %s'
            default = '*' if prefix == config.default_prefix else ' '
            name = (config.root_env_name if prefix == config.root_dir else
                    basename(prefix))
            if not args.json:
                print(fmt % (name, default, prefix))

        for envs_dir in config.envs_dirs:
            if not isdir(envs_dir):
                continue
            for dn in sorted(os.listdir(envs_dir)):
                if dn.startswith('.'):
                    continue
                prefix = join(envs_dir, dn)
                if isdir(prefix):
                    prefix = join(envs_dir, dn)
                    disp_env(prefix)
                    info_dict['envs'].append(prefix)
        disp_env(config.root_dir)
        print()

    if args.system and not args.json:
        import sys

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        print()

        evars = ['PATH', 'PYTHONPATH', 'CONDA_DEFAULT_ENV', 'CIO_TEST',
                 'CONDA_ENVS_PATH']
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 9
0
def execute(args, parser):
    import os
    import sys
    from os.path import basename, dirname, join

    import conda
    import conda.config as config


    options = 'envs', 'system', 'license'

    info_dict = dict(platform=config.subdir,
                     conda_version=conda.__version__,
                     conda_location=dirname(conda.__file__),
                     root_prefix=config.root_dir,
                     default_prefix=config.default_prefix,
                     channels=config.get_channel_urls(),
                     rc_path=config.rc_path)
    if args.json:
        common.stdout_json(info_dict)
        return

    if args.all:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        info_dict['ppcs'] = ('\n' + 24 * ' ').join(info_dict['channels'])
        print("""
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
       conda location : %(conda_location)s
     root environment : %(root_prefix)s
  default environment : %(default_prefix)s
         channel URLs : %(ppcs)s
          config file : %(rc_path)s
""" % info_dict )

    if args.envs:
        print("# conda environments:")
        print("#")
        def disp_env(prefix):
            fmt = '%-20s  %s  %s'
            default = '*' if prefix == config.default_prefix else ' '
            name = (basename(prefix)
                    if prefix.startswith(config.envs_dir) else
                    '(root)')
            print(fmt % (name, default, prefix))

        disp_env(config.root_dir)
        for dn in sorted(os.listdir(config.envs_dir)):
            if os.path.isdir(os.path.join(config.envs_dir, dn)):
                disp_env(join(config.envs_dir, dn))
        print()

    if args.system:
        print()
        print("PATH: %s" % os.getenv('PATH'))
        print("PYTHONPATH: %s" % os.getenv('PYTHONPATH'))
        if config.platform == 'linux':
            print("LD_LIBRARY_PATH: %s" % os.getenv('LD_LIBRARY_PATH'))
        elif sys.platform == 'darwin':
            print("DYLD_LIBRARY_PATH: %s" % os.getenv('DYLD_LIBRARY_PATH'))
        print("CONDA_DEFAULT_ENV: %s" % os.getenv('CONDA_DEFAULT_ENV'))
        print()

    if args.license:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("WARNING: could import _license.show_info,\n"
                  "         try: conda install _license")
Exemplo n.º 10
0
def execute(args, parser):
    if args.args:
        for arg in args.args:
            if isfile(arg):
                from conda.misc import which_package

                path = arg
                for dist in which_package(path):
                    print("%-50s  %s" % (path, dist))
            else:
                show_pkg_info(arg)
        return

    import os
    from os.path import basename, dirname, isdir, join

    import conda
    import conda.config as config
    from conda.cli.main_init import is_initialized

    options = "envs", "system", "license"

    info_dict = dict(
        platform=config.subdir,
        conda_version=conda.__version__,
        root_prefix=config.root_dir,
        root_writable=config.root_writable,
        pkgs_dirs=config.pkgs_dirs,
        envs_dirs=config.envs_dirs,
        default_prefix=config.default_prefix,
        channels=config.get_channel_urls(),
        rc_path=config.rc_path,
        is_foreign=bool(config.foreign),
        envs=[],
    )

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in "pkgs_dirs", "envs_dirs", "channels":
            info_dict["_" + key] = ("\n" + 24 * " ").join(info_dict[key])
        info_dict["_rtwro"] = "writable" if info_dict["root_writable"] else "read only"
        print(
            """\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
"""
            % info_dict
        )
        if not is_initialized():
            print(
                """\
# NOTE:
#     root directory '%s' uninitalized,
#     use 'conda init' to initialize."""
                % config.root_dir
            )

    if args.envs:
        if not args.json:
            print("# conda environments:")
            print("#")

        def disp_env(prefix):
            fmt = "%-20s  %s  %s"
            default = "*" if prefix == config.default_prefix else " "
            name = config.root_env_name if prefix == config.root_dir else basename(prefix)
            if not args.json:
                print(fmt % (name, default, prefix))

        for envs_dir in config.envs_dirs:
            if not isdir(envs_dir):
                continue
            for dn in sorted(os.listdir(envs_dir)):
                if dn.startswith("."):
                    continue
                prefix = join(envs_dir, dn)
                if isdir(prefix):
                    prefix = join(envs_dir, dn)
                    disp_env(prefix)
                    info_dict["envs"].append(prefix)
        disp_env(config.root_dir)
        print()

    if args.system and not args.json:
        import sys
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ["build"])):
            print("conda-%s: %s" % (cmd, find_executable(cmd)))
        print()

        evars = ["PATH", "PYTHONPATH", "CONDA_DEFAULT_ENV", "CIO_TEST", "CONDA_ENVS_PATH"]
        if config.platform == "linux":
            evars.append("LD_LIBRARY_PATH")
        elif config.platform == "osx":
            evars.append("DYLD_LIBRARY_PATH")
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, "<not set>")))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info

            show_info()
        except ImportError:
            print(
                """\
WARNING: could import _license.show_info
# try:
# $ conda install -n root _license"""
            )

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 11
0
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    from conda.base.context import context
    from conda.models.channel import offline_keep
    from conda.resolve import Resolve
    from conda.api import get_index
    from conda.connection import user_agent

    if args.root:
        if context.json:
            stdout_json({'root_prefix': context.root_prefix})
        else:
            print(context.root_prefix)
        return

    if args.packages:
        index = get_index()
        r = Resolve(index)
        if context.json:
            stdout_json({
                package: [dump_record(r.index[d])
                          for d in r.get_dists_for_spec(arg2spec(package))]
                for package in args.packages
            })
        else:
            for package in args.packages:
                for dist in r.get_dists_for_spec(arg2spec(package)):
                    pretty_package(dist, r.index[dist])
        return

    options = 'envs', 'system', 'license'

    try:
        from conda.install import linked_data
        root_pkgs = linked_data(context.root_prefix)
    except:
        root_pkgs = None

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_env
        conda_env_version = conda_env.__version__
    except:
        try:
            cenv = [p for p in itervalues(root_pkgs) if p['name'] == 'conda-env']
            conda_env_version = cenv[0]['version']
        except:
            conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    channels = context.channels

    if args.unsafe_channels:
        if not context.json:
            print("\n".join(channels))
        else:
            print(json.dumps({"channels": channels}))
        return 0

    channels = list(prioritize_channels(channels).keys())
    if not context.json:
        channels = [c + ('' if offline_keep(c) else '  (offline)')
                    for c in channels]
    channels = [mask_anaconda_token(c) for c in channels]

    info_dict = dict(
        platform=context.subdir,
        conda_version=conda.__version__,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=context.root_prefix,
        conda_prefix=context.conda_prefix,
        conda_private=context.conda_private,
        root_writable=context.root_writable,
        pkgs_dirs=context.pkgs_dirs,
        envs_dirs=context.envs_dirs,
        default_prefix=context.default_prefix,
        channels=channels,
        rc_path=rc_path,
        user_rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        # is_foreign=bool(foreign),
        offline=context.offline,
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
        user_agent=user_agent,
    )
    if not on_win:
        info_dict['UID'] = os.geteuid()
        info_dict['GID'] = os.getegid()

    if args.all or context.json:
        for option in options:
            setattr(args, option, True)

    if (args.all or all(not getattr(args, opt) for opt in options)) and not context.json:
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

               platform : %(platform)s
          conda version : %(conda_version)s
       conda is private : %(conda_private)s
      conda-env version : %(conda_env_version)s
    conda-build version : %(conda_build_version)s
         python version : %(python_version)s
       requests version : %(requests_version)s
       root environment : %(root_prefix)s  (%(_rtwro)s)
    default environment : %(default_prefix)s
       envs directories : %(_envs_dirs)s
          package cache : %(_pkgs_dirs)s
           channel URLs : %(_channels)s
            config file : %(rc_path)s
           offline mode : %(offline)s
             user-agent : %(user_agent)s\
""" % info_dict)

        if not on_win:
            print("""\
                UID:GID : %(UID)s:%(GID)s
""" % info_dict)
        else:
            print()

    if args.envs:
        handle_envs_list(info_dict['envs'], not context.json)

    if args.system:
        from conda.cli.find_commands import find_commands, find_executable

        site_dirs = get_user_site()
        evars = ['PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
                 'CIO_TEST', 'CONDA_ENVS_PATH']

        if context.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif context.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')

        if context.json:
            info_dict['sys.version'] = sys.version
            info_dict['sys.prefix'] = sys.prefix
            info_dict['sys.executable'] = sys.executable
            info_dict['site_dirs'] = get_user_site()
            info_dict['env_vars'] = {ev: os.getenv(ev, '<not set>') for ev in evars}
        else:
            print("sys.version: %s..." % (sys.version[:40]))
            print("sys.prefix: %s" % sys.prefix)
            print("sys.executable: %s" % sys.executable)
            print("conda location: %s" % dirname(conda.__file__))
            for cmd in sorted(set(find_commands() + ['build'])):
                print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
            print("user site dirs: ", end='')
            if site_dirs:
                print(site_dirs[0])
            else:
                print()
            for site_dir in site_dirs[1:]:
                print('                %s' % site_dir)
            print()

            for ev in sorted(evars):
                print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
            print()

    if args.license and not context.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if context.json:
        stdout_json(info_dict)
Exemplo n.º 12
0
def execute(args, parser):
    if args.args:
        for arg in args.args:
            if isfile(arg):
                from conda.misc import which_package
                path = arg
                for dist in which_package(path):
                    print('%-50s  %s' % (path, dist))
            else:
                show_pkg_info(arg)
        return

    import os
    from os.path import basename, dirname, isdir, join

    import conda
    import conda.config as config
    from conda.cli.main_init import is_initialized

    options = 'envs', 'system', 'license'

    info_dict = dict(
        platform=config.subdir,
        conda_version=conda.__version__,
        root_prefix=config.root_dir,
        root_writable=config.root_writable,
        pkgs_dirs=config.pkgs_dirs,
        envs_dirs=config.envs_dirs,
        default_prefix=config.default_prefix,
        channels=config.get_channel_urls(),
        rc_path=config.rc_path,
        is_foreign=bool(config.foreign),
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
    )

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable'
                               if info_dict['root_writable'] else 'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
       python version : %(python_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' uninitalized,
#     use 'conda init' to initialize.""" % config.root_dir)

    if args.envs:
        if not args.json:
            print("# conda environments:")
            print("#")

        def disp_env(prefix):
            fmt = '%-20s  %s  %s'
            default = '*' if prefix == config.default_prefix else ' '
            name = (config.root_env_name
                    if prefix == config.root_dir else basename(prefix))
            if not args.json:
                print(fmt % (name, default, prefix))

        for envs_dir in config.envs_dirs:
            if not isdir(envs_dir):
                continue
            for dn in sorted(os.listdir(envs_dir)):
                if dn.startswith('.'):
                    continue
                prefix = join(envs_dir, dn)
                if isdir(prefix):
                    prefix = join(envs_dir, dn)
                    disp_env(prefix)
                    info_dict['envs'].append(prefix)
        disp_env(config.root_dir)
        print()

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable(cmd)))
        print()

        evars = [
            'PATH', 'PYTHONPATH', 'CONDA_DEFAULT_ENV', 'CIO_TEST',
            'CONDA_ENVS_PATH'
        ]
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 13
0
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    import conda.config as config
    from conda.resolve import Resolve
    from conda.cli.main_init import is_initialized
    from conda.api import get_index

    if args.root:
        if args.json:
            common.stdout_json({'root_prefix': config.root_dir})
        else:
            print(config.root_dir)
        return

    if args.packages:
        index = get_index()
        r = Resolve(index)
        if args.json:
            common.stdout_json({
                package: [p._asdict()
                          for p in sorted(r.get_pkgs(common.arg2spec(package)))]
                for package in args.packages
            })
        else:
            for package in args.packages:
                versions = r.get_pkgs(common.arg2spec(package))
                for pkg in sorted(versions):
                    pretty_package(pkg)
        return

    options = 'envs', 'system', 'license'

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    # this is a hack associated with channel weight until we get the package cache reworked
    #   in a future release
    # for now, just ordering the channels for display in a semi-plausible way
    d = defaultdict(list)
    any(d[v[1]].append(k) for k, v in iteritems(config.get_channel_urls()))
    channels = list(chain.from_iterable(d[q] for q in sorted(d, reverse=True)))

    info_dict = dict(
        platform=config.subdir,
        conda_version=conda.__version__,
        conda_build_version=conda_build_version,
        root_prefix=config.root_dir,
        root_writable=config.root_writable,
        pkgs_dirs=config.pkgs_dirs,
        envs_dirs=config.envs_dirs,
        default_prefix=config.default_prefix,
        channels=channels,
        rc_path=config.rc_path,
        user_rc_path=config.user_rc_path,
        sys_rc_path=config.sys_rc_path,
        is_foreign=bool(config.foreign),
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
    )

    if args.unsafe_channels:
        if not args.json:
            print("\n".join(info_dict["channels"]))
        else:
            print(json.dumps({"channels": info_dict["channels"]}))
        return 0
    else:
        info_dict['channels'] = [config.hide_binstar_tokens(c) for c in
                                 info_dict['channels']]
    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable' if info_dict['root_writable'] else
                               'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' is uninitialized""" % config.root_dir)

    if args.envs:
        common.handle_envs_list(info_dict['envs'], not args.json)

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
        print("user site dirs: ", end='')
        site_dirs = get_user_site()
        if site_dirs:
            print(site_dirs[0])
        else:
            print()
        for site_dir in site_dirs[1:]:
            print('                %s' % site_dir)
        print()

        evars = ['PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
                 'CIO_TEST', 'CONDA_ENVS_PATH']
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 14
0
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    from conda.base.context import context
    from conda.models.channel import offline_keep
    from conda.resolve import Resolve
    from conda.api import get_index
    from conda.connection import user_agent

    if args.root:
        if context.json:
            stdout_json({'root_prefix': context.root_dir})
        else:
            print(context.root_dir)
        return

    if args.packages:
        index = get_index()
        r = Resolve(index)
        if context.json:
            stdout_json({
                package: [
                    dump_record(r.index[d])
                    for d in r.get_dists_for_spec(arg2spec(package))
                ]
                for package in args.packages
            })
        else:
            for package in args.packages:
                for dist in r.get_dists_for_spec(arg2spec(package)):
                    pretty_package(dist, r.index[dist])
        return

    options = 'envs', 'system', 'license'

    try:
        from conda.install import linked_data
        root_pkgs = linked_data(context.root_prefix)
    except:
        root_pkgs = None

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_env
        conda_env_version = conda_env.__version__
    except:
        try:
            cenv = [
                p for p in itervalues(root_pkgs) if p['name'] == 'conda-env'
            ]
            conda_env_version = cenv[0]['version']
        except:
            conda_env_version = "not installed"

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    channels = context.channels

    if args.unsafe_channels:
        if not context.json:
            print("\n".join(channels))
        else:
            print(json.dumps({"channels": channels}))
        return 0

    channels = list(prioritize_channels(channels).keys())
    if not context.json:
        channels = [
            c + ('' if offline_keep(c) else '  (offline)') for c in channels
        ]
    channels = [mask_anaconda_token(c) for c in channels]

    info_dict = dict(
        platform=context.subdir,
        conda_version=conda.__version__,
        conda_env_version=conda_env_version,
        conda_build_version=conda_build_version,
        root_prefix=context.root_dir,
        conda_prefix=context.conda_prefix,
        conda_private=context.conda_private,
        root_writable=context.root_writable,
        pkgs_dirs=context.pkgs_dirs,
        envs_dirs=context.envs_dirs,
        default_prefix=context.default_prefix,
        channels=channels,
        rc_path=rc_path,
        user_rc_path=user_rc_path,
        sys_rc_path=sys_rc_path,
        # is_foreign=bool(foreign),
        offline=context.offline,
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
        user_agent=user_agent,
    )
    if not on_win:
        info_dict['UID'] = os.geteuid()
        info_dict['GID'] = os.getegid()

    if args.all or context.json:
        for option in options:
            setattr(args, option, True)

    if (args.all or all(not getattr(args, opt)
                        for opt in options)) and not context.json:
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable'
                               if info_dict['root_writable'] else 'read only')
        print("""\
Current conda install:

               platform : %(platform)s
          conda version : %(conda_version)s
       conda is private : %(conda_private)s
      conda-env version : %(conda_env_version)s
    conda-build version : %(conda_build_version)s
         python version : %(python_version)s
       requests version : %(requests_version)s
       root environment : %(root_prefix)s  (%(_rtwro)s)
    default environment : %(default_prefix)s
       envs directories : %(_envs_dirs)s
          package cache : %(_pkgs_dirs)s
           channel URLs : %(_channels)s
            config file : %(rc_path)s
           offline mode : %(offline)s
             user-agent : %(user_agent)s\
""" % info_dict)

        if not on_win:
            print("""\
                UID:GID : %(UID)s:%(GID)s
""" % info_dict)
        else:
            print()

    if args.envs:
        handle_envs_list(info_dict['envs'], not context.json)

    if args.system:
        from conda.cli.find_commands import find_commands, find_executable

        site_dirs = get_user_site()
        evars = [
            'PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
            'CIO_TEST', 'CONDA_ENVS_PATH'
        ]

        if context.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif context.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')

        if context.json:
            info_dict['sys.version'] = sys.version
            info_dict['sys.prefix'] = sys.prefix
            info_dict['sys.executable'] = sys.executable
            info_dict['site_dirs'] = get_user_site()
            info_dict['env_vars'] = {
                ev: os.getenv(ev, '<not set>')
                for ev in evars
            }
        else:
            print("sys.version: %s..." % (sys.version[:40]))
            print("sys.prefix: %s" % sys.prefix)
            print("sys.executable: %s" % sys.executable)
            print("conda location: %s" % dirname(conda.__file__))
            for cmd in sorted(set(find_commands() + ['build'])):
                print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
            print("user site dirs: ", end='')
            if site_dirs:
                print(site_dirs[0])
            else:
                print()
            for site_dir in site_dirs[1:]:
                print('                %s' % site_dir)
            print()

            for ev in sorted(evars):
                print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
            print()

    if args.license and not context.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if context.json:
        stdout_json(info_dict)
Exemplo n.º 15
0
def execute(args, parser):
    import os
    from os.path import basename, dirname, isdir, join

    import conda
    import conda.config as config
    import conda.misc as misc
    from conda.cli.main_init import is_initialized
    from conda.api import get_package_versions, app_is_installed
    from conda.install import is_linked

    if args.args:
        results = defaultdict(list)

        for arg in args.args:
            if isfile(arg):
                from conda.misc import which_package
                path = arg
                for dist in which_package(path):
                    if args.json:
                        results[arg].append(dist)
                    else:
                        print('%-50s  %s' % (path, dist))
            elif arg.endswith('.tar.bz2'):
                info = None
                for prefix in misc.list_prefixes():
                    info = is_linked(prefix, arg[:-8])
                    if info:
                        break

                if not info:
                    if args.json:
                        results[arg] = {'installed': []}
                    else:
                        print("Package %s is not installed" % arg)

                    continue

                info['installed'] = app_is_installed(arg)
                if args.json:
                    results[arg] = info
                else:
                    print(arg)
                    print('    %-15s %30s' %
                          ('installed', bool(info.get('installed'))))

                    for key in ('name', 'version', 'build', 'license',
                                'platform', 'arch', 'size', 'summary'):
                        print('    %-15s %30s' % (key, info.get(key)))
            else:
                if args.json:
                    for pkg in get_package_versions(arg):
                        results[arg].append(pkg._asdict())
                else:
                    show_pkg_info(arg)

        if args.json:
            common.stdout_json(results)
        return

    options = 'envs', 'system', 'license'

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    info_dict = dict(
        platform=config.subdir,
        conda_version=conda.__version__,
        conda_build_version=conda_build_version,
        root_prefix=config.root_dir,
        root_writable=config.root_writable,
        pkgs_dirs=config.pkgs_dirs,
        envs_dirs=config.envs_dirs,
        default_prefix=config.default_prefix,
        channels=config.get_channel_urls(),
        rc_path=config.rc_path,
        is_foreign=bool(config.foreign),
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
    )

    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    t_pat = re.compile(r'binstar\.org/(t/[0-9a-f\-]{4,})')
    info_dict['channels_disp'] = [
        t_pat.sub('binstar.org/t/<TOKEN>', c) for c in info_dict['channels']
    ]

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels_disp':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable'
                               if info_dict['root_writable'] else 'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels_disp)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' uninitalized,
#     use 'conda init' to initialize.""" % config.root_dir)

    del info_dict['channels_disp']

    if args.envs:
        if not args.json:
            print("# conda environments:")
            print("#")

        def disp_env(prefix):
            fmt = '%-20s  %s  %s'
            default = '*' if prefix == config.default_prefix else ' '
            name = (config.root_env_name
                    if prefix == config.root_dir else basename(prefix))
            if not args.json:
                print(fmt % (name, default, prefix))

        for prefix in misc.list_prefixes():
            disp_env(prefix)
            if prefix != config.root_dir:
                info_dict['envs'].append(prefix)

        print()

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable(cmd)))
        print()

        evars = [
            'PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
            'CIO_TEST', 'CONDA_ENVS_PATH'
        ]
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)
Exemplo n.º 16
0
def execute(args, parser):
    import os
    from os.path import dirname

    import conda
    import conda.config as config
    from conda.resolve import Resolve
    from conda.cli.main_init import is_initialized
    from conda.api import get_index, get_package_versions

    if args.root:
        if args.json:
            common.stdout_json({'root_prefix': config.root_dir})
        else:
            print(config.root_dir)
        return

    if args.packages:
        if args.json:
            results = defaultdict(list)
            for arg in args.packages:
                for pkg in get_package_versions(arg):
                    results[arg].append(pkg._asdict())
            common.stdout_json(results)
            return
        index = get_index()
        r = Resolve(index)
        specs = map(common.arg2spec, args.packages)

        for spec in specs:
            versions = r.get_pkgs(spec)
            for pkg in sorted(versions):
                pretty_package(pkg)
        return

    options = 'envs', 'system', 'license'

    try:
        import requests
        requests_version = requests.__version__
    except ImportError:
        requests_version = "could not import"
    except Exception as e:
        requests_version = "Error %s" % e

    try:
        import conda_build
    except ImportError:
        conda_build_version = "not installed"
    except Exception as e:
        conda_build_version = "Error %s" % e
    else:
        conda_build_version = conda_build.__version__

    # this is a hack associated with channel weight until we get the package cache reworked
    #   in a future release
    # for now, just ordering the channels for display in a semi-plausible way
    d = defaultdict(list)
    any(d[v[1]].append(k) for k, v in iteritems(config.get_channel_urls()))
    channels = list(chain.from_iterable(d[q] for q in sorted(d, reverse=True)))

    info_dict = dict(
        platform=config.subdir,
        conda_version=conda.__version__,
        conda_build_version=conda_build_version,
        root_prefix=config.root_dir,
        root_writable=config.root_writable,
        pkgs_dirs=config.pkgs_dirs,
        envs_dirs=config.envs_dirs,
        default_prefix=config.default_prefix,
        channels=channels,
        rc_path=config.rc_path,
        user_rc_path=config.user_rc_path,
        sys_rc_path=config.sys_rc_path,
        is_foreign=bool(config.foreign),
        envs=[],
        python_version='.'.join(map(str, sys.version_info)),
        requests_version=requests_version,
    )

    if args.unsafe_channels:
        if not args.json:
            print("\n".join(info_dict["channels"]))
        else:
            print(json.dumps({"channels": info_dict["channels"]}))
        return 0
    else:
        info_dict['channels'] = [
            config.hide_binstar_tokens(c) for c in info_dict['channels']
        ]
    if args.all or args.json:
        for option in options:
            setattr(args, option, True)

    if args.all or all(not getattr(args, opt) for opt in options):
        for key in 'pkgs_dirs', 'envs_dirs', 'channels':
            info_dict['_' + key] = ('\n' + 24 * ' ').join(info_dict[key])
        info_dict['_rtwro'] = ('writable'
                               if info_dict['root_writable'] else 'read only')
        print("""\
Current conda install:

             platform : %(platform)s
        conda version : %(conda_version)s
  conda-build version : %(conda_build_version)s
       python version : %(python_version)s
     requests version : %(requests_version)s
     root environment : %(root_prefix)s  (%(_rtwro)s)
  default environment : %(default_prefix)s
     envs directories : %(_envs_dirs)s
        package cache : %(_pkgs_dirs)s
         channel URLs : %(_channels)s
          config file : %(rc_path)s
    is foreign system : %(is_foreign)s
""" % info_dict)
        if not is_initialized():
            print("""\
# NOTE:
#     root directory '%s' is uninitialized""" % config.root_dir)

    if args.envs:
        common.handle_envs_list(info_dict['envs'], not args.json)

    if args.system and not args.json:
        from conda.cli.find_commands import find_commands, find_executable

        print("sys.version: %s..." % (sys.version[:40]))
        print("sys.prefix: %s" % sys.prefix)
        print("sys.executable: %s" % sys.executable)
        print("conda location: %s" % dirname(conda.__file__))
        for cmd in sorted(set(find_commands() + ['build'])):
            print("conda-%s: %s" % (cmd, find_executable('conda-' + cmd)))
        print("user site dirs: ", end='')
        site_dirs = get_user_site()
        if site_dirs:
            print(site_dirs[0])
        else:
            print()
        for site_dir in site_dirs[1:]:
            print('                %s' % site_dir)
        print()

        evars = [
            'PATH', 'PYTHONPATH', 'PYTHONHOME', 'CONDA_DEFAULT_ENV',
            'CIO_TEST', 'CONDA_ENVS_PATH'
        ]
        if config.platform == 'linux':
            evars.append('LD_LIBRARY_PATH')
        elif config.platform == 'osx':
            evars.append('DYLD_LIBRARY_PATH')
        for ev in sorted(evars):
            print("%s: %s" % (ev, os.getenv(ev, '<not set>')))
        print()

    if args.license and not args.json:
        try:
            from _license import show_info
            show_info()
        except ImportError:
            print("""\
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license""")

    if args.json:
        common.stdout_json(info_dict)