def checksum(parser, args): # Did the user pass 'package@version' string? if len(args.versions) == 0 and '@' in args.package: args.versions = [args.package.split('@')[1]] args.package = args.package.split('@')[0] # Make sure the user provided a package and not a URL if not valid_fully_qualified_module_name(args.package): tty.die("`spack checksum` accepts package names, not URLs.") # Get the package we're going to generate checksums for pkg = spack.repo.get(args.package) url_dict = {} if args.versions: # If the user asked for specific versions, use those for version in args.versions: version = ver(version) if not isinstance(version, Version): tty.die("Cannot generate checksums for version lists or " "version ranges. Use unambiguous versions.") url_dict[version] = pkg.url_for_version(version) elif args.preferred: version = preferred_version(pkg) url_dict = dict([(version, pkg.url_for_version(version))]) else: # Otherwise, see what versions we can find online url_dict = pkg.fetch_remote_versions() if not url_dict: tty.die("Could not find any versions for {0}".format(pkg.name)) # And ensure the specified version URLs take precedence, if available try: explicit_dict = {} for v in pkg.versions: if not v.isdevelop(): explicit_dict[v] = pkg.url_for_version(v) url_dict.update(explicit_dict) except spack.package.NoURLError: pass version_lines = spack.stage.get_checksums_for_versions( url_dict, pkg.name, keep_stage=args.keep_stage, batch=(args.batch or len(args.versions) > 0 or len(url_dict) == 1), latest=args.latest, fetch_options=pkg.fetch_options) print() print(version_lines) print()
def checksum(parser, args): # Did the user pass 'package@version' string? if len(args.versions) == 0 and '@' in args.package: args.versions = [args.package.split('@')[1]] args.package = args.package.split('@')[0] # Make sure the user provided a package and not a URL if not valid_fully_qualified_module_name(args.package): tty.die("`spack checksum` accepts package names, not URLs.") # Get the package we're going to generate checksums for pkg = spack.repo.get(args.package) url_dict = {} versions = args.versions if (not versions) and args.preferred: versions = [preferred_version(pkg)] if versions: remote_versions = None for version in versions: version = ver(version) if not isinstance(version, Version): tty.die("Cannot generate checksums for version lists or " "version ranges. Use unambiguous versions.") url = pkg.find_valid_url_for_version(version) if url is not None: url_dict[version] = url continue # if we get here, it's because no valid url was provided by the package # do expensive fallback to try to recover if remote_versions is None: remote_versions = pkg.fetch_remote_versions() if version in remote_versions: url_dict[version] = remote_versions[version] else: url_dict = pkg.fetch_remote_versions() if not url_dict: tty.die("Could not find any versions for {0}".format(pkg.name)) version_lines = spack.stage.get_checksums_for_versions( url_dict, pkg.name, keep_stage=args.keep_stage, batch=(args.batch or len(args.versions) > 0 or len(url_dict) == 1), latest=args.latest, fetch_options=pkg.fetch_options) print() print(version_lines) print()
def print_versions(pkg): """output versions""" color.cprint('') color.cprint(section_title('Preferred version: ')) if not pkg.versions: color.cprint(version(' None')) color.cprint('') color.cprint(section_title('Safe versions: ')) color.cprint(version(' None')) color.cprint('') color.cprint(section_title('Deprecated versions: ')) color.cprint(version(' None')) else: pad = padder(pkg.versions, 4) preferred = preferred_version(pkg) url = '' if pkg.has_code: url = fs.for_package_version(pkg, preferred) line = version(' {0}'.format(pad(preferred))) + color.cescape(url) color.cprint(line) safe = [] deprecated = [] for v in reversed(sorted(pkg.versions)): if pkg.has_code: url = fs.for_package_version(pkg, v) if pkg.versions[v].get('deprecated', False): deprecated.append((v, url)) else: safe.append((v, url)) for title, vers in [('Safe', safe), ('Deprecated', deprecated)]: color.cprint('') color.cprint(section_title('{0} versions: '.format(title))) if not vers: color.cprint(version(' None')) continue for v, url in vers: line = version(' {0}'.format(pad(v))) + color.cescape(url) color.cprint(line)
def print_text_info(pkg): """Print out a plain text description of a package.""" header = section_title('{0}: ').format(pkg.build_system_class) + pkg.name color.cprint(header) color.cprint('') color.cprint(section_title('Description:')) if pkg.__doc__: color.cprint(color.cescape(pkg.format_doc(indent=4))) else: color.cprint(" None") color.cprint(section_title('Homepage: ') + pkg.homepage) if len(pkg.maintainers) > 0: mnt = " ".join(['@@' + m for m in pkg.maintainers]) color.cprint('') color.cprint(section_title('Maintainers: ') + mnt) color.cprint('') color.cprint(section_title('Externally Detectable: ')) # If the package has an 'executables' field, it can detect an installation if hasattr(pkg, 'executables'): find_attributes = [] if hasattr(pkg, 'determine_version'): find_attributes.append('version') if hasattr(pkg, 'determine_variants'): find_attributes.append('variants') # If the package does not define 'determine_version' nor # 'determine_variants', then it must use some custom detection # mechanism. In this case, just inform the user it's detectable somehow. color.cprint(' True{0}'.format(' (' + ', '.join(find_attributes) + ')' if find_attributes else '')) else: color.cprint(' False') color.cprint('') color.cprint(section_title("Tags: ")) if hasattr(pkg, 'tags'): tags = sorted(pkg.tags) colify(tags, indent=4) else: color.cprint(" None") color.cprint('') color.cprint(section_title('Preferred version: ')) if not pkg.versions: color.cprint(version(' None')) color.cprint('') color.cprint(section_title('Safe versions: ')) color.cprint(version(' None')) color.cprint('') color.cprint(section_title('Deprecated versions: ')) color.cprint(version(' None')) else: pad = padder(pkg.versions, 4) preferred = preferred_version(pkg) url = '' if pkg.has_code: url = fs.for_package_version(pkg, preferred) line = version(' {0}'.format(pad(preferred))) + color.cescape(url) color.cprint(line) safe = [] deprecated = [] for v in reversed(sorted(pkg.versions)): if pkg.has_code: url = fs.for_package_version(pkg, v) if pkg.versions[v].get('deprecated', False): deprecated.append((v, url)) else: safe.append((v, url)) for title, vers in [('Safe', safe), ('Deprecated', deprecated)]: color.cprint('') color.cprint(section_title('{0} versions: '.format(title))) if not vers: color.cprint(version(' None')) continue for v, url in vers: line = version(' {0}'.format(pad(v))) + color.cescape(url) color.cprint(line) color.cprint('') color.cprint(section_title('Variants:')) formatter = VariantFormatter(pkg.variants) for line in formatter.lines: color.cprint(color.cescape(line)) if hasattr(pkg, 'phases') and pkg.phases: color.cprint('') color.cprint(section_title('Installation Phases:')) phase_str = '' for phase in pkg.phases: phase_str += " {0}".format(phase) color.cprint(phase_str) for deptype in ('build', 'link', 'run'): color.cprint('') color.cprint(section_title('%s Dependencies:' % deptype.capitalize())) deps = sorted(pkg.dependencies_of_type(deptype)) if deps: colify(deps, indent=4) else: color.cprint(' None') color.cprint('') color.cprint(section_title('Virtual Packages: ')) if pkg.provided: inverse_map = {} for spec, whens in pkg.provided.items(): for when in whens: if when not in inverse_map: inverse_map[when] = set() inverse_map[when].add(spec) for when, specs in reversed(sorted(inverse_map.items())): line = " %s provides %s" % (when.colorized(), ', '.join( s.colorized() for s in specs)) print(line) else: color.cprint(" None") color.cprint('')