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) # XXX: Make this work with more than one platform platform = args.platform or '' 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, platform=args.platform) r = Resolve(index) for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue if args.outdated: vers_inst = [ dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name ] if not vers_inst: continue assert len(vers_inst) == 1, name pkgs = sorted(r.get_pkgs(MatchSpec(name))) if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: 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 %-15s %s' % ( disp_name, inst, pkg.version, r.index[pkg.fn]['build'], canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = ''
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) # XXX: Make this work with more than one platform platform = args.platform or '' 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, platform=args.platform) r = Resolve(index) for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue if args.outdated: vers_inst = [dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name pkgs = sorted(r.get_pkgs(MatchSpec(name))) if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: 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 %-15s %s' % ( disp_name, inst, pkg.version, r.index[pkg.fn]['build'], canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = ''
def show_pkg_info(name): from conda.api import get_index from conda.resolve import Resolve index = get_index() r = Resolve(index) print(name) if name in r.groups: for pkg in sorted(r.get_pkgs(name)): print(' %-15s %15s %s' % (pkg.version, pkg.build, disp_features(r.features(pkg.fn)))) else: print(' not available')
def show_pkg_info(name): #import conda.install as install from conda.api import get_index from conda.resolve import MatchSpec, Resolve index = get_index() r = Resolve(index) print(name) if name in r.groups: for pkg in sorted(r.get_pkgs(MatchSpec(name))): print(' %-15s %15s %s' % (pkg.version, pkg.build, common.disp_features(r.features(pkg.fn)))) else: print(' not available')
def show_pkg_info(name): from conda.api import get_index from conda.resolve import Resolve index = get_index() r = Resolve(index) print(name) if name in r.groups: for pkg in sorted(r.get_pkgs(name)): print(' %-15s %15s %s' % ( pkg.version, pkg.build, common.disp_features(r.features(pkg.fn)))) else: print(' not available')
def show_pkg_info(name): #import conda.install as install from conda.api import get_index from conda.resolve import MatchSpec, Resolve index = get_index() r = Resolve(index) print(name) if name in r.groups: for pkg in sorted(r.get_pkgs(MatchSpec(name))): print(' %-15s %15s %s' % ( pkg.version, pkg.build, common.disp_features(r.features(pkg.fn)))) else: print(' not available on channels')
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 = ''
def remove_features_actions(prefix, index, features): linked = install.linked(prefix) r = Resolve(index) actions = defaultdict(list) actions[PREFIX] = prefix _linked = [d + '.tar.bz2' for d in linked] to_link = [] for dist in sorted(linked): fn = dist + '.tar.bz2' if fn not in index: continue if r.track_features(fn).intersection(features): actions[UNLINK].append(dist) if r.features(fn).intersection(features): actions[UNLINK].append(dist) subst = r.find_substitute(_linked, features, fn) if subst: to_link.append(subst[:-8]) if to_link: actions.update(ensure_linked_actions(to_link, prefix)) return actions
def execute_search(args, parser): import re import sys from conda.api import get_index from conda.resolve import MatchSpec, Resolve pat = None ms = None if args.regex: if args.spec: ms = MatchSpec(' '.join(args.regex.split('='))) else: try: pat = re.compile(args.regex, re.I) except re.error as e: common.error_and_exit("%r is not a valid regex pattern (exception: %s)" % (args.regex, e), json=args.json, error_type="ValueError") prefix = common.get_prefix(args) import conda.config import conda.install linked = conda.install.linked(prefix) extracted = set() for pkgs_dir in conda.config.pkgs_dirs: extracted.update(conda.install.extracted(pkgs_dir)) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != config.subdir: args.unknown = False common.ensure_override_channels_requires_channel(args, dashc=False, json=args.json) channel_urls = args.channel or () index = common.get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, platform=args.platform, use_cache=args.use_index_cache, unknown=args.unknown, json=args.json) r = Resolve(index) if args.canonical: json = [] else: json = {} for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue if ms and name != ms.name: continue if ms: ms_name = ms else: ms_name = MatchSpec(name) if not args.canonical: json[name] = [] if args.outdated: vers_inst = [dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name pkgs = sorted(r.get_pkgs(ms_name)) if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue for pkg in sorted(r.get_pkgs(ms_name)): dist = pkg.fn[:-8] if args.canonical: if not args.json: print(dist) else: json.append(dist) continue if dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' if not args.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, config.canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = '' else: data = {} data.update(pkg.info) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': config.canonical_channel_name(pkg.channel), 'full_channel': pkg.channel, 'features': list(r.features(pkg.fn)), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if args.json: common.stdout_json(json)
def execute_search(args, parser): import re from conda.resolve import Resolve if args.reverse_dependency: if not args.regex: parser.error("--reverse-dependency requires at least one package name") if args.spec: parser.error("--reverse-dependency does not work with --spec") pat = None ms = None if args.regex: if args.spec: ms = ' '.join(args.regex.split('=')) else: regex = args.regex if args.full_name: regex = r'^%s$' % regex try: pat = re.compile(regex, re.I) except re.error as e: raise CondaValueError("'%s' is not a valid regex pattern (exception: %s)" % (regex, e), args.json) prefix = get_prefix(args) import conda.install linked = conda.install.linked(prefix) extracted = conda.install.extracted() # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != subdir: args.unknown = False ensure_use_local(args) ensure_override_channels_requires_channel(args, dashc=False) channel_urls = args.channel or () index = get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, platform=args.platform, use_local=args.use_local, use_cache=args.use_index_cache, prefix=prefix, unknown=args.unknown, json=args.json) r = Resolve(index) if args.canonical: json = [] else: json = {} names = [] for name in sorted(r.groups): if '@' in name: continue if args.reverse_dependency: ms_name = ms for pkg in r.groups[name]: for dep in r.ms_depends(pkg): if pat.search(dep.name): names.append((name, Package(pkg, r.index[pkg]))) else: if pat and pat.search(name) is None: continue if ms and name != ms.split()[0]: continue if ms: ms_name = ms else: ms_name = name pkgs = sorted(r.get_pkgs(ms_name)) names.append((name, pkgs)) if args.reverse_dependency: new_names = [] old = None for name, pkg in sorted(names, key=lambda x: (x[0], x[1].name, x[1])): if name == old: new_names[-1][1].append(pkg) else: new_names.append((name, [pkg])) old = name names = new_names for name, pkgs in names: if args.reverse_dependency: disp_name = pkgs[0].name else: disp_name = name if args.names_only and not args.outdated: print(name) continue if not args.canonical: json[name] = [] if args.outdated: vers_inst = [dist[1] for dist in map(dist2quad, linked) if dist[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue if args.names_only: print(name) continue for pkg in pkgs: dist = pkg.fn[:-8] if args.canonical: if not args.json: print(dist) else: json.append(dist) continue if platform and platform != subdir: inst = ' ' elif dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' if not args.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, canonical_channel_name(pkg.channel), disp_features(r.features(pkg.fn)), )) disp_name = '' else: data = {} data.update(pkg.info) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': canonical_channel_name(pkg.channel), 'full_channel': pkg.channel, 'features': list(r.features(pkg.fn)), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if args.json: stdout_json(json)
def execute(args, parser): import re import sys from conda.api import get_index from conda.resolve import MatchSpec, Resolve if args.regex: try: pat = re.compile(args.regex, re.I) except re.error as e: sys.exit("Error: %r is not a valid regex pattern (exception: %s)" % (args.regex, e)) else: pat = None prefix = common.get_prefix(args) if not args.canonical: import conda.config import conda.install linked = conda.install.linked(prefix) extracted = set() for pkgs_dir in conda.config.pkgs_dirs: extracted.update(conda.install.extracted(pkgs_dir)) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != config.subdir: args.unknown = False 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, platform=args.platform, use_cache=args.use_index_cache, unknown=args.unknown) r = Resolve(index) for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue if args.outdated: vers_inst = [dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name pkgs = sorted(r.get_pkgs(MatchSpec(name))) if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue for pkg in sorted(r.get_pkgs(MatchSpec(name))): dist = pkg.fn[:-8] if args.canonical: print(dist) continue if dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, r.index[pkg.fn]['build'], config.canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = ''
def execute_search(args, parser): import re from conda.resolve import Resolve if args.reverse_dependency: if not args.regex: parser.error( "--reverse-dependency requires at least one package name") if args.spec: parser.error("--reverse-dependency does not work with --spec") pat = None ms = None if args.regex: if args.spec: ms = ' '.join(args.regex.split('=')) else: regex = args.regex if args.full_name: regex = r'^%s$' % regex try: pat = re.compile(regex, re.I) except re.error as e: raise CommandArgumentError( "Failed to compile regex pattern for " "search: %(regex)s\n" "regex error: %(regex_error)s", regex=regex, regex_error=repr(e)) prefix = context.prefix_w_legacy_search from ..core.linked_data import linked as linked_data from ..core.package_cache import PackageCache linked = linked_data(prefix) extracted = set(pc_entry.dist.name for pc_entry in PackageCache.get_all_extracted_entries()) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != context.subdir: args.unknown = False ensure_use_local(args) 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, platform=args.platform, use_local=args.use_local, use_cache=args.use_index_cache, prefix=None, unknown=args.unknown) r = Resolve(index) if args.canonical: json = [] else: json = {} names = [] for name in sorted(r.groups): if '@' in name: continue if args.reverse_dependency: ms_name = ms for pkg in r.groups[name]: for dep in r.ms_depends(pkg): if pat.search(dep.name): names.append((name, Package(pkg, r.index[pkg]))) else: if pat and pat.search(name) is None: continue if ms and name != ms.split()[0]: continue if ms: ms_name = ms else: ms_name = name pkgs = sorted(r.get_pkgs(ms_name)) names.append((name, pkgs)) if args.reverse_dependency: new_names = [] old = None for name, pkg in sorted(names, key=lambda x: (x[0], x[1].name, x[1])): if name == old: new_names[-1][1].append(pkg) else: new_names.append((name, [pkg])) old = name names = new_names for name, pkgs in names: if args.reverse_dependency: disp_name = pkgs[0].name else: disp_name = name if args.names_only and not args.outdated: print(name) continue if not args.canonical: json[name] = [] if args.outdated: vers_inst = [ dist.quad[1] for dist in linked if dist.quad[0] == name ] if not vers_inst: continue assert len(vers_inst) == 1, name if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue if args.names_only: print(name) continue for pkg in pkgs: dist = Dist(pkg) if args.canonical: if not context.json: print(dist.dist_name) else: json.append(dist.dist_name) continue if platform and platform != context.subdir: inst = ' ' elif dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' features = r.features(dist) if not context.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, pkg.schannel, disp_features(features), )) disp_name = '' else: data = {} data.update(pkg.info.dump()) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': pkg.schannel, 'full_channel': pkg.channel, 'features': list(features), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if context.json: stdout_json(json)
def execute_search(args, parser): import re from conda.resolve import MatchSpec, Resolve if args.reverse_dependency: if not args.regex: parser.error("--reverse-dependency requires at least one package name") if args.spec: parser.error("--reverse-dependency does not work with --spec") pat = None ms = None if args.regex: if args.spec: ms = MatchSpec(' '.join(args.regex.split('='))) else: regex = args.regex if args.full_name: regex = r'^%s$' % regex try: pat = re.compile(regex, re.I) except re.error as e: common.error_and_exit( "'%s' is not a valid regex pattern (exception: %s)" % (regex, e), json=args.json, error_type="ValueError") prefix = common.get_prefix(args) import conda.config import conda.install linked = conda.install.linked(prefix) extracted = set() for pkgs_dir in conda.config.pkgs_dirs: extracted.update(conda.install.extracted(pkgs_dir)) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != config.subdir: args.unknown = False common.ensure_override_channels_requires_channel(args, dashc=False, json=args.json) channel_urls = args.channel or () if args.use_local: from conda.fetch import fetch_index from conda.utils import url_path try: from conda_build.config import croot except ImportError: common.error_and_exit("you need to have 'conda-build >= 1.7.1' installed" " to use the --use-local option", json=args.json, error_type="RuntimeError") # remove the cache such that a refetch is made, # this is necessary because we add the local build repo URL fetch_index.cache = {} index = common.get_index_trap(channel_urls=[url_path(croot)] + list(channel_urls), prepend=not args.override_channels, use_cache=args.use_index_cache, unknown=args.unknown, json=args.json, platform=args.platform, offline=args.offline) else: index = common.get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, platform=args.platform, use_cache=args.use_index_cache, unknown=args.unknown, json=args.json, offline=args.offline) r = Resolve(index) if args.canonical: json = [] else: json = {} names = [] for name in sorted(r.groups): if args.reverse_dependency: ms_name = ms for pkg in r.groups[name]: for dep in r.ms_depends(pkg): if pat.search(dep.name): names.append((name, Package(pkg, r.index[pkg]))) else: if pat and pat.search(name) is None: continue if ms and name != ms.name: continue if ms: ms_name = ms else: ms_name = MatchSpec(name) pkgs = sorted(r.get_pkgs(ms_name)) names.append((name, pkgs)) if args.reverse_dependency: new_names = [] old = None for name, pkg in sorted(names, key=lambda x:(x[0], x[1].name, x[1])): if name == old: new_names[-1][1].append(pkg) else: new_names.append((name, [pkg])) old = name names = new_names for name, pkgs in names: if args.reverse_dependency: disp_name = pkgs[0].name else: disp_name = name if args.names_only and not args.outdated: print(name) continue if not args.canonical: json[name] = [] if args.outdated: vers_inst = [dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue if args.names_only: print(name) continue for pkg in pkgs: dist = pkg.fn[:-8] if args.canonical: if not args.json: print(dist) else: json.append(dist) continue if platform and platform != config.subdir: inst = ' ' elif dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' if not args.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, config.canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = '' else: data = {} data.update(pkg.info) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': config.canonical_channel_name(pkg.channel), 'full_channel': pkg.channel, 'features': list(r.features(pkg.fn)), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if args.json: common.stdout_json(json)
def execute_search(args, parser): import re from conda.resolve import Resolve if args.reverse_dependency: if not args.regex: parser.error( "--reverse-dependency requires at least one package name") if args.spec: parser.error("--reverse-dependency does not work with --spec") pat = None ms = None if args.regex: if args.spec: ms = ' '.join(args.regex.split('=')) else: regex = args.regex if args.full_name: regex = r'^%s$' % regex try: pat = re.compile(regex, re.I) except re.error as e: error_and_exit( "'%s' is not a valid regex pattern (exception: %s)" % (regex, e), json=args.json, error_type="ValueError") prefix = get_prefix(args) import conda.install linked = conda.install.linked(prefix) extracted = conda.install.extracted() # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != subdir: args.unknown = False ensure_use_local(args) ensure_override_channels_requires_channel(args, dashc=False) channel_urls = args.channel or () index = get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, platform=args.platform, use_local=args.use_local, use_cache=args.use_index_cache, prefix=prefix, unknown=args.unknown, json=args.json, offline=args.offline) r = Resolve(index) if args.canonical: json = [] else: json = {} names = [] for name in sorted(r.groups): if '@' in name: continue if args.reverse_dependency: ms_name = ms for pkg in r.groups[name]: for dep in r.ms_depends(pkg): if pat.search(dep.name): names.append((name, Package(pkg, r.index[pkg]))) else: if pat and pat.search(name) is None: continue if ms and name != ms.split()[0]: continue if ms: ms_name = ms else: ms_name = name pkgs = sorted(r.get_pkgs(ms_name)) names.append((name, pkgs)) if args.reverse_dependency: new_names = [] old = None for name, pkg in sorted(names, key=lambda x: (x[0], x[1].name, x[1])): if name == old: new_names[-1][1].append(pkg) else: new_names.append((name, [pkg])) old = name names = new_names for name, pkgs in names: if args.reverse_dependency: disp_name = pkgs[0].name else: disp_name = name if args.names_only and not args.outdated: print(name) continue if not args.canonical: json[name] = [] if args.outdated: vers_inst = [ dist[1] for dist in map(dist2quad, linked) if dist[0] == name ] if not vers_inst: continue assert len(vers_inst) == 1, name if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue if args.names_only: print(name) continue for pkg in pkgs: dist = pkg.fn[:-8] if args.canonical: if not args.json: print(dist) else: json.append(dist) continue if platform and platform != subdir: inst = ' ' elif dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' if not args.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, canonical_channel_name(pkg.channel), disp_features(r.features(pkg.fn)), )) disp_name = '' else: data = {} data.update(pkg.info) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': canonical_channel_name(pkg.channel), 'full_channel': pkg.channel, 'features': list(r.features(pkg.fn)), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if args.json: stdout_json(json)
def execute_search(args, parser): import re import sys from conda.api import get_index from conda.resolve import MatchSpec, Resolve pat = None ms = None if args.regex: if args.spec: ms = MatchSpec(' '.join(args.regex.split('='))) else: try: pat = re.compile(args.regex, re.I) except re.error as e: common.error_and_exit("%r is not a valid regex pattern (exception: %s)" % (args.regex, e), json=args.json, error_type="ValueError") prefix = common.get_prefix(args) if not args.canonical: import conda.config import conda.install linked = conda.install.linked(prefix) extracted = set() for pkgs_dir in conda.config.pkgs_dirs: extracted.update(conda.install.extracted(pkgs_dir)) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != config.subdir: args.unknown = False common.ensure_override_channels_requires_channel(args, dashc=False, json=args.json) channel_urls = args.channel or () index = common.get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, platform=args.platform, use_cache=args.use_index_cache, unknown=args.unknown, json=args.json) r = Resolve(index) if args.canonical: json = [] else: json = {} for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue if ms and name != ms.name: continue if ms: ms_name = ms else: ms_name = MatchSpec(name) if not args.canonical: json[name] = [] if args.outdated: vers_inst = [dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name pkgs = sorted(r.get_pkgs(ms_name)) if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue for pkg in sorted(r.get_pkgs(ms_name)): dist = pkg.fn[:-8] if args.canonical: if not args.json: print(dist) else: json.append(dist) continue if dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' if not args.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, config.canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = '' else: data = {} data.update(pkg.info) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': config.canonical_channel_name(pkg.channel), 'full_channel': pkg.channel, 'features': list(r.features(pkg.fn)), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if args.json: common.stdout_json(json)
actions[inst.PREFIX] = [prefix] _linked = [d + '.tar.bz2' for d in linked] to_link = [] for dist in sorted(linked): fn = dist + '.tar.bz2' if fn not in index: continue if r.track_features(fn).intersection(features): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD add_unlink(actions, dist) if r.features(fn).intersection(features): add_unlink(actions, dist) ======= actions[inst.UNLINK].append((dist,)) if r.features(fn).intersection(features): actions[inst.UNLINK].append((dist,)) >>>>>>> conda/feature/instruction-arguments ======= actions[inst.UNLINK].append((dist,)) if r.features(fn).intersection(features): actions[inst.UNLINK].append((dist,)) >>>>>>> origin/feature/instruction-arguments ======= actions[inst.UNLINK].append((dist,)) if r.features(fn).intersection(features): actions[inst.UNLINK].append((dist,))
def execute_search(args, parser): import re from conda.resolve import Resolve if args.reverse_dependency: if not args.regex: parser.error("--reverse-dependency requires at least one package name") if args.spec: parser.error("--reverse-dependency does not work with --spec") pat = None ms = None if args.regex: if args.spec: ms = ' '.join(args.regex.split('=')) else: regex = args.regex if args.full_name: regex = r'^%s$' % regex try: pat = re.compile(regex, re.I) except re.error as e: common.error_and_exit( "'%s' is not a valid regex pattern (exception: %s)" % (regex, e), json=args.json, error_type="ValueError") prefix = common.get_prefix(args) import conda.config import conda.install linked = conda.install.linked(prefix) extracted = set() for pkgs_dir in conda.config.pkgs_dirs: extracted.update(conda.install.extracted(pkgs_dir)) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != config.subdir: args.unknown = False common.ensure_override_channels_requires_channel(args, dashc=False, json=args.json) channel_urls = args.channel or () if args.use_local: from conda.fetch import fetch_index from conda.utils import url_path try: from conda_build.config import croot except ImportError: common.error_and_exit("you need to have 'conda-build >= 1.7.1' installed" " to use the --use-local option", json=args.json, error_type="RuntimeError") # remove the cache such that a refetch is made, # this is necessary because we add the local build repo URL fetch_index.cache = {} if exists(croot): channel_urls = [url_path(croot)] + list(channel_urls) index = common.get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, use_cache=args.use_index_cache, unknown=args.unknown, prefix=prefix, json=args.json, platform=args.platform, offline=args.offline) else: index = common.get_index_trap(channel_urls=channel_urls, prepend=not args.override_channels, platform=args.platform, use_cache=args.use_index_cache, prefix=prefix, unknown=args.unknown, json=args.json, offline=args.offline) r = Resolve(index) if args.canonical: json = [] else: json = {} names = [] for name in sorted(r.groups): if '@' in name: continue if args.reverse_dependency: ms_name = ms for pkg in r.groups[name]: for dep in r.ms_depends(pkg): if pat.search(dep.name): names.append((name, Package(pkg, r.index[pkg]))) else: if pat and pat.search(name) is None: continue if ms and name != ms.name: continue if ms: ms_name = ms else: ms_name = name pkgs = sorted(r.get_pkgs(ms_name)) names.append((name, pkgs)) if args.reverse_dependency: new_names = [] old = None for name, pkg in sorted(names, key=lambda x:(x[0], x[1].name, x[1])): if name == old: new_names[-1][1].append(pkg) else: new_names.append((name, [pkg])) old = name names = new_names for name, pkgs in names: if args.reverse_dependency: disp_name = pkgs[0].name else: disp_name = name if args.names_only and not args.outdated: print(name) continue if not args.canonical: json[name] = [] if args.outdated: vers_inst = [dist.rsplit('-', 2)[1] for dist in linked if dist.rsplit('-', 2)[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue if args.names_only: print(name) continue for pkg in pkgs: dist = pkg.fn[:-8] if args.canonical: if not args.json: print(dist) else: json.append(dist) continue if platform and platform != config.subdir: inst = ' ' elif dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' if not args.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, config.canonical_channel_name(pkg.channel), common.disp_features(r.features(pkg.fn)), )) disp_name = '' else: data = {} data.update(pkg.info) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': config.canonical_channel_name(pkg.channel), 'full_channel': pkg.channel, 'features': list(r.features(pkg.fn)), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if args.json: common.stdout_json(json)
def execute_search(args, parser): import re from conda.resolve import Resolve if args.reverse_dependency: if not args.regex: parser.error("--reverse-dependency requires at least one package name") if args.spec: parser.error("--reverse-dependency does not work with --spec") pat = None ms = None if args.regex: if args.spec: ms = ' '.join(args.regex.split('=')) else: regex = args.regex if args.full_name: regex = r'^%s$' % regex try: pat = re.compile(regex, re.I) except re.error as e: raise CommandArgumentError("Failed to compile regex pattern for " "search: %(regex)s\n" "regex error: %(regex_error)s", regex=regex, regex_error=repr(e)) prefix = context.prefix_w_legacy_search from ..core.linked_data import linked as linked_data from ..core.package_cache import PackageCache linked = linked_data(prefix) extracted = set(pc_entry.dist.name for pc_entry in PackageCache.get_all_extracted_entries()) # XXX: Make this work with more than one platform platform = args.platform or '' if platform and platform != context.subdir: args.unknown = False ensure_use_local(args) 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, platform=args.platform, use_local=args.use_local, use_cache=args.use_index_cache, prefix=None, unknown=args.unknown) r = Resolve(index) if args.canonical: json = [] else: json = {} names = [] for name in sorted(r.groups): if '@' in name: continue if args.reverse_dependency: ms_name = ms for pkg in r.groups[name]: for dep in r.ms_depends(pkg): if pat.search(dep.name): names.append((name, Package(pkg, r.index[pkg]))) else: if pat and pat.search(name) is None: continue if ms and name != ms.split()[0]: continue if ms: ms_name = ms else: ms_name = name pkgs = sorted(r.get_pkgs(ms_name)) names.append((name, pkgs)) if args.reverse_dependency: new_names = [] old = None for name, pkg in sorted(names, key=lambda x: (x[0], x[1].name, x[1])): if name == old: new_names[-1][1].append(pkg) else: new_names.append((name, [pkg])) old = name names = new_names for name, pkgs in names: if args.reverse_dependency: disp_name = pkgs[0].name else: disp_name = name if args.names_only and not args.outdated: print(name) continue if not args.canonical: json[name] = [] if args.outdated: vers_inst = [dist.quad[1] for dist in linked if dist.quad[0] == name] if not vers_inst: continue assert len(vers_inst) == 1, name if not pkgs: continue latest = pkgs[-1] if latest.version == vers_inst[0]: continue if args.names_only: print(name) continue for pkg in pkgs: dist = Dist(pkg) if args.canonical: if not context.json: print(dist.dist_name) else: json.append(dist.dist_name) continue if platform and platform != context.subdir: inst = ' ' elif dist in linked: inst = '*' elif dist in extracted: inst = '.' else: inst = ' ' features = r.features(dist) if not context.json: print('%-25s %s %-15s %15s %-15s %s' % ( disp_name, inst, pkg.version, pkg.build, pkg.schannel, disp_features(features), )) disp_name = '' else: data = {} data.update(pkg.info.dump()) data.update({ 'fn': pkg.fn, 'installed': inst == '*', 'extracted': inst in '*.', 'version': pkg.version, 'build': pkg.build, 'build_number': pkg.build_number, 'channel': pkg.schannel, 'full_channel': pkg.channel, 'features': list(features), 'license': pkg.info.get('license'), 'size': pkg.info.get('size'), 'depends': pkg.info.get('depends'), 'type': pkg.info.get('type') }) if data['type'] == 'app': data['icon'] = make_icon_url(pkg.info) json[name].append(data) if context.json: stdout_json(json)