mod eb_easyblock¶
- module eb_easyblock¶
Which easyblock class EasyBuild will look for, given a software name.
An easyconfig that names no
easyblockis not asking for a default. There is no default: EasyBuild derives a class name from the software name, tries to import it, and stops with No software-specific easyblock ‘<class>’ found for <name> when it cannot. So the derived name is the difference between a recipe that installs and a recipe that refuses to start, and it is worth being able to compute without a Python interpreter to hand.The rule mirrors
easybuild.tools.filetools:encode_class_nameisEASYBLOCK_CLASS_PREFIXfollowed byencode_string, andencode_stringsubstitutes each character through a fixed map, passing anything unmapped through unchanged.Two properties of that map are easy to get wrong.
_is itself escaped, to_underscore_, which is what keeps the encoding reversible. And the substitution is per character with no collapsing, so a doubled separator doubles:c++becomesEB_c_plus__plus_.Variables
- const EASYBLOCK_CLASS_PREFIX: &str¶
Prefix EasyBuild puts on a derived easyblock class name.
EASYBLOCK_CLASS_PREFIXineasybuild.tools.filetools.
- const STRING_ENCODING_CHARMAP: &[(&str, &str)]¶
Substitutions applied to a software name.
STRING_ENCODING_CHARMAPineasybuild.tools.filetools. The keys are the dict keys as Python stores them.r'\''andr'\\'are the two-character strings\'and\\, not the apostrophe and the backslash.encode_stringlooks each character up on its own, so those two keys are never selected and'and\pass through. Characters absent from this table pass through as well, so letters and digits survive intact.
- const STRING_ENCODING_CHARMAP_COUNT: usize¶
How many substitutions the table carries, for a coverage assertion.
Functions
- fn charmap_document() -> serde_json::Value¶
The encoding table as the JSON document
recipe easyblock --charmapprints.
- fn decode_class_name(class_name: &str) -> String¶
Recover the software name from an encoded class name.
decode_class_nameineasybuild.tools.filetools. A name without the prefix is returned unchanged, since it was never encoded.
- fn decode_string(encoded: &str) -> String¶
Reverse the encoding map.
Longest-match first, because
_underscore_and_share a prefix and taking the shorter one first would strand the rest of the token.
- fn defined_classes(source: &str, path: &str) -> Result<Vec<EasyblockClass>, String>¶
Classes an easyblock module defines, read from its syntax tree.
EasyBuild imports the module and looks a class up by name, so only top-level
classstatements count. The file is parsed, never executed.extra_optionskeys are the string keys of the dict literals in that method’s body, which is how every easyblock in the framework declares them.
- fn easyblock_letter_dir(filename: &str) -> String¶
The directory EasyBuild’s own easyblocks package keeps a module in.
easybuild/easyblocks/<letter>/<module>.py, with the letter taken from the module filename;
--include-easyblocksdoes not need the layout, but an easyblocks PR does, and a bundle that already has it can be diffed against one.
- fn encode_class_name(name: &str) -> String¶
The easyblock class name EasyBuild derives for
name.This says what EasyBuild will look for, not that it exists. A name that has no such class is the case where EasyBuild stops rather than falling back to a generic easyblock.
- fn encode_string(name: &str) -> String¶
Substitute a software name through the encoding map.
encode_stringineasybuild.tools.filetools.
- fn index_easyblocks(roots: &[&std::path::Path]) -> Result<std::collections::BTreeMap<String, (std::path::PathBuf, EasyblockClass)>, String>¶
Where each easyblock class is defined, across trees of
.pyfiles.Roots are searched in order and the first definition of a name wins, which is the precedence
--include-easyblocksgives files over the installed package. A file that does not parse is reported rather than skipped: an easyblock EasyBuild cannot import is a build failure waiting to happen.
Structs and Unions