def list_packages(prefix, regex=None, verbose=True): import re import conda.install as install pat = re.compile(regex, re.I) if regex else None if verbose: print '# packages in environment at %s:' % prefix print '#' for dist in sorted(install.linked(prefix)): name = dist.rsplit('-', 2)[0] if pat and pat.search(name) is None: continue if not verbose: print dist continue try: info = install.is_linked(prefix, dist) features = set(info.get('features', '').split()) print '%-25s %-15s %15s %s' % (info['name'], info['version'], info['build'], common.disp_features(features)) except: # IOError, KeyError, ValueError print '%-25s %-15s %15s' % tuple(dist.rsplit('-', 2))
def execute(args, parser): import re import conda.install as install from conda.api import get_index from conda.resolve import MatchSpec, Resolve if args.regex: pat = re.compile(args.regex, re.I) else: pat = None prefix = common.get_prefix(args) if not args.canonical: linked = install.linked(prefix) common.ensure_override_channels_requires_channel(args, dashc=False) channel_urls = args.channel or () index = get_index(channel_urls=channel_urls, prepend=not args.override_channels) r = Resolve(index) for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue for pkg in sorted(r.get_pkgs(MatchSpec(name))): dist = pkg.fn[:-8] if args.canonical: print dist continue inst = '*' if dist in linked else ' ' print '%-25s %s %-15s %15s %s' % ( disp_name, inst, pkg.version, r.index[pkg.fn]['build'], common.disp_features(r.features(pkg.fn))) disp_name = ''