spack.llnl package¶
Subpackages¶
- spack.llnl.util package
- Subpackages
- spack.llnl.util.tty package
SuppressOutputdebug()debug_level()die()error()error_enabled()get_timestamp()get_yes_or_no()hline()info()is_debug()is_verbose()msg()msg_enabled()output_filter()process_stacktrace()set_debug()set_error_enabled()set_msg_enabled()set_stacktrace()set_timestamp()set_verbose()set_warn_enabled()show_pid()verbose()warn()warn_enabled()- Submodules
- spack.llnl.util.tty.colify module
- spack.llnl.util.tty.color module
- spack.llnl.util.tty.log module
- spack.llnl.util.tty package
- Submodules
- spack.llnl.util.argparsewriter module
ArgparseRstWriterArgparseRstWriter.begin_command()ArgparseRstWriter.begin_optionals()ArgparseRstWriter.begin_positionals()ArgparseRstWriter.begin_subcommands()ArgparseRstWriter.description()ArgparseRstWriter.end_optionals()ArgparseRstWriter.end_positionals()ArgparseRstWriter.format()ArgparseRstWriter.optional()ArgparseRstWriter.positional()ArgparseRstWriter.usage()
ArgparseWriterCommand
- spack.llnl.util.filesystem module
BaseDirectoryVisitorFileFilterFileListHeaderListLibraryListancestor()can_access()change_sed_delimiter()chgrp()chmod_x()copy()copy_mode()copy_tree()filter_file()find()find_all_headers()find_first()find_headers()find_libraries()find_system_libraries()force_remove()force_symlink()getuid()install()install_tree()is_exe()join_path()keep_modification_time()library_extensionsmkdirp()partition_path()prefixes()remove_dead_links()remove_directory_contents()remove_if_dead_link()remove_linked_tree()rename()set_executable()set_install_permissions()touch()touchp()traverse_tree()unset_executable_mode()visit_directory_tree()working_dir()
- spack.llnl.util.lang module
ClassPropertyConstDeprecatedPropertyGroupedExceptionForwarderGroupedExceptionHandlerHashableMapObjectWrapperPriorityOrderedMappingSingletonSingletonInstantiationErrorTypedMutableSequenceUnhashableArgumentsattr_setdefault()classpropertydecorator_with_or_without_args()dedupe()doneelide_list()ensure_last()fnmatch_translate_multiple()get_entry_points()index_by()key_ordering()lazy_eq()lazy_lexicographic_ordering()lazy_lt()list_modules()load_module_from_file()match_predicate()memoized()nullcontext()pretty_date()pretty_duration()pretty_seconds()pretty_seconds_formatter()pretty_string_to_date()stable_partition()tuplify()uniq()
- spack.llnl.util.link_tree module
- spack.llnl.util.lock module
- spack.llnl.util.symlink module
- Subpackages
Submodules¶
spack.llnl.path module¶
Path primitives that just require Python standard library.
- spack.llnl.path.convert_to_platform_path(path: str) str[source]¶
Converts the input path to the current platform’s native style.
- spack.llnl.path.convert_to_posix_path(path: str) str[source]¶
Converts the input path to POSIX style.
- spack.llnl.path.format_os_path(path: str, mode: int = Path.unix) str[source]¶
Formats the input path to use consistent, platform specific separators.
Absolute paths are converted between drive letters and a prepended
/as per platform requirement.- Parameters:
path – the path to be normalized, must be a string or expose the replace method.
mode – the path file separator style to normalize the passed path to. Default is unix style, i.e.
/
- spack.llnl.path.path_to_os_path(*parameters: str) List[str][source]¶
Takes an arbitrary number of positional parameters, converts each argument of type string to use a normalized filepath separator, and returns a list of all values.
spack.llnl.string module¶
String manipulation functions that do not have other dependencies than Python standard library
- spack.llnl.string.comma_and(sequence: List[str]) str[source]¶
Return a string with all the elements of the input joined by comma, but the last one (which is joined by
"and").
- spack.llnl.string.comma_or(sequence: Sequence[str]) str[source]¶
Return a string with all the elements of the input joined by comma, but the last one (which is joined by
"or").
- spack.llnl.string.ordinal(number: int) str[source]¶
Return the ordinal representation (1st, 2nd, 3rd, etc.) for the provided number.
- Parameters:
number – int to convert to ordinal number
Returns: number’s corresponding ordinal
- spack.llnl.string.plural(n: int, singular: str, plural: str | None = None, show_n: bool = True) str[source]¶
Pluralize <singular> word by adding an s if n != 1.
- Parameters:
n – number of things there are
singular – singular form of word
plural – optional plural form, for when it’s not just singular + ‘s’
show_n – whether to include n in the result string (default True)
- Returns:
“1 thing” if n == 1 or “n things” if n != 1
spack.llnl.url module¶
URL primitives that just require Python standard library.
- spack.llnl.url.allowed_archive(path_or_url: str) bool[source]¶
Returns true if the input is a valid archive, False otherwise.
- spack.llnl.url.check_and_remove_ext(path: str, *, extension: str) str[source]¶
Returns the input path with the extension removed, if the extension is present in path. Otherwise, returns the input unchanged.
- spack.llnl.url.compression_ext_from_compressed_archive(extension: str) str | None[source]¶
Returns compression extension for a compressed archive
- spack.llnl.url.determine_url_file_extension(path: str) str[source]¶
This returns the type of archive a URL refers to. This is sometimes confusing because of URLs like:
https://github.com/petdance/ack/tarball/1.93_02
Where the URL doesn’t actually contain the filename. We need to know what type it is so that we can appropriately name files in mirrors.
- spack.llnl.url.expand_contracted_extension(extension: str) str[source]¶
Returns the expanded version of a known contracted extension.
This function maps extensions like
.tgzto.tar.gz. On unknown extensions, return the input unmodified.
- spack.llnl.url.expand_contracted_extension_in_path(path_or_url: str, *, extension: str | None = None) str[source]¶
Returns the input path or URL with any contraction extension expanded.
- Parameters:
path_or_url – path or URL to be expanded
extension – if specified, only attempt to expand that extension
- spack.llnl.url.extension_from_path(path_or_url: str | None) str | None[source]¶
Tries to match an allowed archive extension to the input. Returns the first match, or None if no match was found.
- Raises:
ValueError – if the input is None
- spack.llnl.url.find_list_urls(url: str) Set[str][source]¶
Find good list URLs for the supplied URL.
By default, returns the dirname of the archive path.
Provides special treatment for the following websites, which have a unique list URL different from the dirname of the download URL:
GitHub
https://github.com/<repo>/<name>/releasesGitLab
https://gitlab.\*/<repo>/<name>/tagsBitBucket
https://bitbucket.org/<repo>/<name>/downloads/?tab=tagsCRAN
https://\*.r-project.org/src/contrib/Archive/<name>PyPI
https://pypi.org/simple/<name>/LuaRocks
https://luarocks.org/modules/<repo>/<name>Note: this function is called by
spack versions,spack checksum, andspack create, but not byspack fetchorspack install.
- spack.llnl.url.has_extension(path_or_url: str, ext: str) bool[source]¶
Returns true if the extension in input is present in path, false otherwise.
- spack.llnl.url.remove_extension(path_or_url: str, *, extension: str) str[source]¶
Returns the input with the extension removed
- spack.llnl.url.split_url_extension(url: str) Tuple[str, ...][source]¶
Some URLs have a query string, e.g.:
https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7.tgz?raw=truehttp://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin.tar.gzhttps://gitlab.kitware.com/vtk/vtk/repository/archive.tar.bz2?ref=v7.0.0
In (1), the query string needs to be stripped to get at the extension, but in (2) & (3), the filename is IN a single final query argument.
This strips the URL into three pieces:
prefix,ext, andsuffix. The suffix contains anything that was stripped off the URL to get at the file extension. In (1), it will be'?raw=true', but in (2), it will be empty. In (3) the suffix is a parameter that follows after the file extension, e.g.:('https://github.com/losalamos/CLAMR/blob/packages/PowerParser_v2.0.7', '.tgz', '?raw=true')('http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.0/apache-cassandra-1.2.0-rc2-bin', '.tar.gz', None)('https://gitlab.kitware.com/vtk/vtk/repository/archive', '.tar.bz2', '?ref=v7.0.0')
- spack.llnl.url.split_url_on_sourceforge_suffix(url: str) Tuple[str, ...][source]¶
If the input is a sourceforge URL, returns base URL and
/downloadsuffix. Otherwise, returns the input URL and an empty string.
- spack.llnl.url.strip_compression_extension(path_or_url: str, ext: str | None = None) str[source]¶
Strips the compression extension from the input, and returns it. For instance,
"foo.tgz"becomes"foo.tar".If no extension is given, try a default list of extensions.
- Parameters:
path_or_url – input to be stripped
ext – if given, extension to be stripped
- spack.llnl.url.strip_extension(path_or_url: str, *, extension: str | None = None) str[source]¶
If a path contains the extension in input, returns the path stripped of the extension. Otherwise, returns the input path.
If extension is None, attempts to strip any allowed extension from path.
- spack.llnl.url.strip_query_and_fragment(url: str) Tuple[str, str][source]¶
Strips query and fragment from a url, then returns the base url and the suffix.
- Parameters:
url – URL to be stripped
- Raises:
ValueError – when there is any error parsing the URL
- spack.llnl.url.strip_version_suffixes(path_or_url: str) str[source]¶
Some tarballs contain extraneous information after the version:
bowtie2-2.2.5-sourcelibevent-2.0.21-stablecuda_8.0.44_linux.run
These strings are not part of the version number and should be ignored. This function strips those suffixes off and returns the remaining string. The goal is that the version is always the last thing in
path:bowtie2-2.2.5libevent-2.0.21cuda_8.0.44
- Parameters:
path_or_url – The filename or URL for the package
- Returns:
The
pathwith any extraneous suffixes removed