def print_text_info(pkg): """Print out a plain text description of a package.""" print "Package: ", pkg.name print "Homepage: ", pkg.homepage print print "Safe versions: " if not pkg.versions: print(" None") else: pad = padder(pkg.versions, 4) for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) print " %s%s" % (pad(v), str(f)) print print "Variants:" if not pkg.variants: print " None" else: pad = padder(pkg.variants, 4) maxv = max(len(v) for v in sorted(pkg.variants)) fmt = "%%-%ss%%-10s%%s" % (maxv + 4) print " " + fmt % ('Name', 'Default', 'Description') print for name in sorted(pkg.variants): v = pkg.variants[name] default = 'on' if v.default else 'off' lines = textwrap.wrap(v.description) lines[1:] = [" " + (" " * maxv) + l for l in lines[1:]] desc = "\n".join(lines) print " " + fmt % (name, default, desc) print print "Dependencies:" if pkg.dependencies: colify(pkg.dependencies, indent=4) else: print " None" print print "Virtual packages: " if pkg.provided: for spec, when in pkg.provided.items(): print " %s provides %s" % (when, spec) else: print " None" print print "Description:" if pkg.__doc__: print pkg.format_doc(indent=4) else: print " None"
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 info_text(pkg): """Print out a plain text description of a package.""" print "Package: ", pkg.name print "Homepage: ", pkg.homepage print print "Safe versions: " if not pkg.versions: print("None.") else: maxlen = max(len(str(v)) for v in pkg.versions) fmt = "%%-%ss" % maxlen for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) print " " + (fmt % v) + " " + str(f) print print "Dependencies:" if pkg.dependencies: colify(pkg.dependencies, indent=4) else: print " None" print print "Virtual packages: " if pkg.provided: for spec, when in pkg.provided.items(): print " %s provides %s" % (when, spec) else: print " None" print print "Description:" if pkg.__doc__: print format_doc(pkg, indent=4) else: print " None"
def print_text_info(pkg): """Print out a plain text description of a package.""" print "Package: ", pkg.name print "Homepage: ", pkg.homepage print print "Safe versions: " if not pkg.versions: print("None.") else: maxlen = max(len(str(v)) for v in pkg.versions) fmt = "%%-%ss" % maxlen for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) print " " + (fmt % v) + " " + str(f) print print "Dependencies:" if pkg.dependencies: colify(pkg.dependencies, indent=4) else: print " None" print print "Virtual packages: " if pkg.provided: for spec, when in pkg.provided.items(): print " %s provides %s" % (when, spec) else: print " None" print print "Description:" if pkg.__doc__: print pkg.format_doc(indent=4) else: print " None"
def url_stats(args): class UrlStats(object): def __init__(self): self.total = 0 self.schemes = defaultdict(lambda: 0) self.checksums = defaultdict(lambda: 0) self.url_type = defaultdict(lambda: 0) self.git_type = defaultdict(lambda: 0) def add(self, fetcher): self.total += 1 url_type = fetcher.url_attr self.url_type[url_type or 'no code'] += 1 if url_type == 'url': digest = getattr(fetcher, 'digest', None) if digest: algo = crypto.hash_algo_for_digest(digest) else: algo = 'no checksum' self.checksums[algo] += 1 # parse out the URL scheme (https/http/ftp/etc.) urlinfo = urllib_parse.urlparse(fetcher.url) self.schemes[urlinfo.scheme] += 1 elif url_type == 'git': if getattr(fetcher, 'commit', None): self.git_type['commit'] += 1 elif getattr(fetcher, 'branch', None): self.git_type['branch'] += 1 elif getattr(fetcher, 'tag', None): self.git_type['tag'] += 1 else: self.git_type['no ref'] += 1 npkgs = 0 version_stats = UrlStats() resource_stats = UrlStats() for pkg in spack.repo.path.all_packages(): npkgs += 1 for v, args in pkg.versions.items(): fetcher = fs.for_package_version(pkg, v) version_stats.add(fetcher) for _, resources in pkg.resources.items(): for resource in resources: resource_stats.add(resource.fetcher) # print a nice summary table tty.msg("URL stats for %d packages:" % npkgs) def print_line(): print("-" * 62) def print_stat(indent, name, stat_name=None): width = 20 - indent fmt = " " * indent fmt += "%%-%ds" % width if stat_name is None: print(fmt % name) else: fmt += "%12d%8.1f%%%12d%8.1f%%" v = getattr(version_stats, stat_name).get(name, 0) r = getattr(resource_stats, stat_name).get(name, 0) print(fmt % (name, v, v / version_stats.total * 100, r, r / resource_stats.total * 100)) print_line() print("%-20s%12s%9s%12s%9s" % ("stat", "versions", "%", "resources", "%")) print_line() print_stat(0, "url", "url_type") print_stat(4, "schemes") schemes = set(version_stats.schemes) | set(resource_stats.schemes) for scheme in schemes: print_stat(8, scheme, "schemes") print_stat(4, "checksums") checksums = set(version_stats.checksums) | set(resource_stats.checksums) for checksum in checksums: print_stat(8, checksum, "checksums") print_line() types = set(version_stats.url_type) | set(resource_stats.url_type) types -= set(["url", "git"]) for url_type in sorted(types): print_stat(0, url_type, "url_type") print_line() print_stat(0, "git", "url_type") git_types = set(version_stats.git_type) | set(resource_stats.git_type) for git_type in sorted(git_types): print_stat(4, git_type, "git_type") print_line()
def create(path, specs, **kwargs): """Create a directory to be used as a spack mirror, and fill it with package archives. Arguments: path Path to create a mirror directory hierarchy in. specs Any package versions matching these specs will be added to the mirror. Keyword args: no_checksum: If True, do not checkpoint when fetching (default False) num_versions: Max number of versions to fetch per spec, if spec is ambiguous (default is 0 for all of them) Return Value: Returns a tuple of lists: (present, mirrored, error) * present: Package specs that were already prsent. * mirrored: Package specs that were successfully mirrored. * error: Package specs that failed to mirror due to some error. This routine iterates through all known package versions, and it creates specs for those versions. If the version satisfies any spec in the specs list, it is downloaded and added to the mirror. """ # Make sure nothing is in the way. if os.path.isfile(path): raise MirrorError("%s already exists and is a file." % path) # automatically spec-ify anything in the specs array. specs = [s if isinstance(s, Spec) else Spec(s) for s in specs] # Get concrete specs for each matching version of these specs. version_specs = get_matching_versions( specs, num_versions=kwargs.get('num_versions', 0)) for s in version_specs: s.concretize() # Get the absolute path of the root before we start jumping around. mirror_root = os.path.abspath(path) if not os.path.isdir(mirror_root): mkdirp(mirror_root) # Things to keep track of while parsing specs. present = [] mirrored = [] error = [] # Iterate through packages and download all the safe tarballs for each of them for spec in version_specs: pkg = spec.package stage = None try: # create a subdirectory for the current package@version archive_path = os.path.abspath(join_path(path, mirror_archive_path(spec))) subdir = os.path.dirname(archive_path) mkdirp(subdir) if os.path.exists(archive_path): tty.msg("Already added %s" % spec.format("$_$@")) present.append(spec) continue # Set up a stage and a fetcher for the download unique_fetch_name = spec.format("$_$@") fetcher = fs.for_package_version(pkg, pkg.version) stage = Stage(fetcher, name=unique_fetch_name) fetcher.set_stage(stage) # Do the fetch and checksum if necessary fetcher.fetch() if not kwargs.get('no_checksum', False): fetcher.check() tty.msg("Checksum passed for %s@%s" % (pkg.name, pkg.version)) # Fetchers have to know how to archive their files. Use # that to move/copy/create an archive in the mirror. fetcher.archive(archive_path) tty.msg("Added %s." % spec.format("$_$@")) mirrored.append(spec) except Exception, e: if spack.debug: sys.excepthook(*sys.exc_info()) else: tty.warn("Error while fetching %s." % spec.format('$_$@'), e.message) error.append(spec) finally:
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("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')) else: pad = padder(pkg.versions, 4) # Here we sort first on the fact that a version is marked # as preferred in the package, then on the fact that the # version is not develop, then lexicographically key_fn = lambda v: (pkg.versions[v].get('preferred', False), not v.isdevelop(), v) preferred = sorted(pkg.versions, key=key_fn).pop() f = fs.for_package_version(pkg, preferred) line = version(' {0}'.format(pad(preferred))) + color.cescape(f) color.cprint(line) color.cprint('') color.cprint(section_title('Safe versions: ')) for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) line = version(' {0}'.format(pad(v))) + color.cescape(f) color.cprint(line) color.cprint('') color.cprint(section_title('Variants:')) formatter = VariantFormatter(pkg.variants) for line in formatter.lines: color.cprint(line) 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('')
def url_stats(args): stats = {} # stats about fetchers in packages. nvers = 0 # total number of versions npkgs = 0 # total number of packages def inc(fstype, category, attr=None): """Increment statistics in the stats dict.""" categories = stats.setdefault(fstype, {}) if attr: cat_stats = categories.setdefault(category, {}) val = cat_stats.setdefault(attr, 0) stats[fstype][category][attr] = val + 1 else: val = categories.setdefault(category, 0) stats[fstype][category] = val + 1 # over all packages for pkg in spack.repo.path.all_packages(): npkgs += 1 # look at each version for v, args in pkg.versions.items(): # figure out what type of fetcher it is fetcher = fs.for_package_version(pkg, v) nvers += 1 fstype = fetcher.url_attr inc(fstype, 'total') # put some special stats in for particular types of fetchers. if fstype == 'git': if 'commit' in args: inc('git', 'security', 'commit') else: inc('git', 'security', 'no commit') elif fstype == 'url': for h in crypto.hashes: if h in args: inc('url', 'checksums', h) break else: if 'checksum' in args: h = crypto.hash_algo_for_digest(args['checksum']) inc('url', 'checksums', h) else: inc('url', 'checksums', 'no checksum') # parse out the URL scheme (https/http/ftp/etc.) urlinfo = urlparse(fetcher.url) inc('url', 'schemes', urlinfo.scheme) # print a nice summary table tty.msg("%d total versions for %d packages:" % (nvers, npkgs)) line_width = 36 print("-" * line_width) for fetcher, fetcher_stats in sorted(stats.items(), reverse=True): fs_total = fetcher_stats['total'] fs_pct = float(fs_total) / nvers * 100 print("%-22s%5d%8.1f%%" % (fetcher, fs_total, fs_pct)) for category, cat_stats in sorted(fetcher_stats.items(), reverse=True): if category == 'total': continue print(" %s" % category) for name, number in sorted(cat_stats.items(), reverse=True): pct = float(number) / fs_total * 100 print(" %-18s%5d%8.1f%%" % (name, number, pct)) print("-" * line_width)
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('')
def url_stats(args): # dictionary of issue type -> package -> descriptions issues = defaultdict(lambda: defaultdict(lambda: [])) class UrlStats(object): def __init__(self): self.total = 0 self.schemes = defaultdict(lambda: 0) self.checksums = defaultdict(lambda: 0) self.url_type = defaultdict(lambda: 0) self.git_type = defaultdict(lambda: 0) def add(self, pkg_name, fetcher): self.total += 1 url_type = fetcher.url_attr self.url_type[url_type or 'no code'] += 1 if url_type == 'url': digest = getattr(fetcher, 'digest', None) if digest: algo = crypto.hash_algo_for_digest(digest) else: algo = 'no checksum' self.checksums[algo] += 1 if algo == "md5": md5_hashes = issues["md5 hashes"] md5_hashes[pkg_name].append(fetcher.url) # parse out the URL scheme (https/http/ftp/etc.) urlinfo = urllib_parse.urlparse(fetcher.url) self.schemes[urlinfo.scheme] += 1 if urlinfo.scheme == "http": http_urls = issues["http urls"] http_urls[pkg_name].append(fetcher.url) elif url_type == 'git': if getattr(fetcher, 'commit', None): self.git_type['commit'] += 1 elif getattr(fetcher, 'branch', None): self.git_type['branch'] += 1 elif getattr(fetcher, 'tag', None): self.git_type['tag'] += 1 else: self.git_type['no ref'] += 1 npkgs = 0 version_stats = UrlStats() resource_stats = UrlStats() for pkg_cls in spack.repo.path.all_package_classes(): npkgs += 1 for v in pkg_cls.versions: try: pkg = pkg_cls(spack.spec.Spec(pkg_cls.name)) fetcher = fs.for_package_version(pkg, v) except (fs.InvalidArgsError, fs.FetcherConflict): continue version_stats.add(pkg_cls.name, fetcher) for _, resources in pkg_cls.resources.items(): for resource in resources: resource_stats.add(pkg_cls.name, resource.fetcher) # print a nice summary table tty.msg("URL stats for %d packages:" % npkgs) def print_line(): print("-" * 62) def print_stat(indent, name, stat_name=None): width = 20 - indent fmt = " " * indent fmt += "%%-%ds" % width if stat_name is None: print(fmt % name) else: fmt += "%12d%8.1f%%%12d%8.1f%%" v = getattr(version_stats, stat_name).get(name, 0) r = getattr(resource_stats, stat_name).get(name, 0) print(fmt % (name, v, v / version_stats.total * 100, r, r / resource_stats.total * 100)) print_line() print("%-20s%12s%9s%12s%9s" % ("stat", "versions", "%", "resources", "%")) print_line() print_stat(0, "url", "url_type") print_stat(4, "schemes") schemes = set(version_stats.schemes) | set(resource_stats.schemes) for scheme in schemes: print_stat(8, scheme, "schemes") print_stat(4, "checksums") checksums = set(version_stats.checksums) | set(resource_stats.checksums) for checksum in checksums: print_stat(8, checksum, "checksums") print_line() types = set(version_stats.url_type) | set(resource_stats.url_type) types -= set(["url", "git"]) for url_type in sorted(types): print_stat(0, url_type, "url_type") print_line() print_stat(0, "git", "url_type") git_types = set(version_stats.git_type) | set(resource_stats.git_type) for git_type in sorted(git_types): print_stat(4, git_type, "git_type") print_line() if args.show_issues: total_issues = sum( len(issues) for _, pkg_issues in issues.items() for _, issues in pkg_issues.items()) print() tty.msg("Found %d issues." % total_issues) for issue_type, pkgs in issues.items(): tty.msg("Package URLs with %s" % issue_type) for pkg_cls, pkg_issues in pkgs.items(): color.cprint(" @*C{%s}" % pkg_cls) for issue in pkg_issues: print(" %s" % issue)
def print_text_info(pkg): """Print out a plain text description of a package.""" header = "{0}: ".format(pkg.build_system_class) print header, pkg.name whitespaces = ''.join([' '] * (len(header) - len("Homepage: "))) print "Homepage:", whitespaces, pkg.homepage print print "Safe versions: " if not pkg.versions: print(" None") else: pad = padder(pkg.versions, 4) for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) print " %s%s" % (pad(v), str(f)) print print "Variants:" if not pkg.variants: print " None" else: pad = padder(pkg.variants, 4) maxv = max(len(v) for v in sorted(pkg.variants)) fmt = "%%-%ss%%-10s%%s" % (maxv + 4) print " " + fmt % ('Name', 'Default', 'Description') print for name in sorted(pkg.variants): v = pkg.variants[name] default = 'on' if v.default else 'off' lines = textwrap.wrap(v.description) lines[1:] = [" " + (" " * maxv) + l for l in lines[1:]] desc = "\n".join(lines) print " " + fmt % (name, default, desc) print print "Installation Phases:" phase_str = '' for phase in pkg.phases: phase_str += " {0}".format(phase) print phase_str for deptype in ('build', 'link', 'run'): print print "%s Dependencies:" % deptype.capitalize() deps = sorted(pkg.dependencies_of_type(deptype)) if deps: colify(deps, indent=4) else: print " None" print print "Virtual Packages: " if pkg.provided: for spec, when in pkg.provided.items(): print " %s provides %s" % (when, spec) else: print " None" print print "Description:" if pkg.__doc__: print pkg.format_doc(indent=4) else: print " None"
def print_text_info(pkg): """Print out a plain text description of a package.""" header = "{0}: ".format(pkg.build_system_class) print header, pkg.name whitespaces = ''.join([' '] * (len(header) - len("Homepage: "))) print "Homepage:", whitespaces, pkg.homepage print print "Safe versions: " if not pkg.versions: print(" None") else: pad = padder(pkg.versions, 4) for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) print " %s%s" % (pad(v), str(f)) print print "Variants:" if not pkg.variants: print " None" else: pad = padder(pkg.variants, 4) maxv = max(len(v) for v in sorted(pkg.variants)) fmt = "%%-%ss%%-10s%%s" % (maxv + 4) print " " + fmt % ('Name', 'Default', 'Description') print for name in sorted(pkg.variants): v = pkg.variants[name] default = 'on' if v.default else 'off' lines = textwrap.wrap(v.description) lines[1:] = [" " + (" " * maxv) + l for l in lines[1:]] desc = "\n".join(lines) print " " + fmt % (name, default, desc) print print "Installation Phases:" phase_str = '' for phase in pkg.phases: phase_str += " {0}".format(phase) print phase_str for deptype in ('build', 'link', 'run'): print print "%s Dependencies:" % deptype.capitalize() deps = sorted(pkg.dependencies_of_type(deptype)) if deps: colify(deps, indent=4) else: print " None" print print "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())): print " %s provides %s" % ( when, ', '.join(str(s) for s in specs)) else: print " None" print print "Description:" if pkg.__doc__: print pkg.format_doc(indent=4) else: print " None"
def print_text_info(pkg): """Print out a plain text description of a package.""" header = "{0}: ".format(pkg.build_system_class) print(header, pkg.name) whitespaces = ''.join([' '] * (len(header) - len("Homepage: "))) print("Homepage:", whitespaces, pkg.homepage) print() print("Safe versions: ") if not pkg.versions: print(" None") else: pad = padder(pkg.versions, 4) for v in reversed(sorted(pkg.versions)): f = fs.for_package_version(pkg, v) print(" %s%s" % (pad(v), str(f))) print() print("Variants:") formatter = VariantFormatter(pkg.variants) for line in formatter.lines: print(line) print() print("Installation Phases:") phase_str = '' for phase in pkg.phases: phase_str += " {0}".format(phase) print(phase_str) for deptype in ('build', 'link', 'run'): print() print("%s Dependencies:" % deptype.capitalize()) deps = sorted(pkg.dependencies_of_type(deptype)) if deps: colify(deps, indent=4) else: print(" None") print() print("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())): print(" %s provides %s" % ( when, ', '.join(str(s) for s in specs))) else: print(" None") print() print("Description:") if pkg.__doc__: print(pkg.format_doc(indent=4)) else: print(" None")
def _tweak_dev_package_fetcher(dp, spec): """Attempt to configure the package's fetcher and stage to obtain the source we want to develop for this package. """ if dp.tag_or_branch is None: # Nothing to do. return fetcher_Version = None spack_package = spec.package # We want the tag or branch specified in dp. package_Version = Version(dp.tag_or_branch) develop_Version = Version('develop') if package_Version in spack_package.versions and \ _version_is_vc(spack_package, package_Version): # Specified version is version-controlled. fetcher_Version = package_Version elif not fetcher_Version and \ develop_Version in spack_package.versions and \ _version_is_vc(spack_package, develop_Version): # Repurpose develop to obtain the tag/branch we need. version_dict = spack_package.versions[develop_Version] # Attempt to tweak things to check out our desired tag or branch. if 'git' in version_dict: # Git. version_dict.pop('commit', None) if dp.key == 'tag': version_dict['tag'] = dp.tag_or_branch version_dict.pop('branch', None) else: # Branch. version_dict['branch'] = dp.tag_or_branch version_dict.pop('tag', None) elif 'hg' in version_dict: # Mercury version_dict['revision'] = dp.tag_or_branch elif 'svn' in version_dict: # Subversion. # Can't reliably do anything here since SVN URL structure is # convention only, and it is also not possible to reliably # distinguish between two common conventions # ('project/<trunk-or-branches-or-tags>' vs # '<trunk-or-branches-or-tags>/project'. raise ExtrapolationError( 'For subversion repositories, a VC version corresponding to ' '{0} must be defined in the recipe for {1}.'.format( dp.tag_or_branch, dp.name)) else: raise SpackError('INTERNAL ERROR: spack dev cannot handle ' 'apparently-supported VC method\n' 'version_dict = {0}'.format(version_dict)) fetcher_Version = develop_Version if fetcher_Version: version_dict = spack_package.versions[fetcher_Version] version_dict['no_cache'] = True # Disable caching. if 'git' in version_dict: # Disable efficiency options that aren't wanted here. version_dict.update({'full_depth': True, 'all_branches': True}) spack_package.fetcher = fs.for_package_version(spack_package, fetcher_Version) spack_package.stage = Stage(spack_package.fetcher, path=spack_package.path) else: tty.warn('Spack dev unable to obtain VC source for package {0} {1}' '\nFalling back to version {2} as concretized'.format( dp.name, 'with user-specified {0} {1}'.format( dp.key, dp.tag_or_branch) if dp.key else '', spack_package.version))