rez.suite
- class rez.suite.Suite[source]
Bases:
objectA collection of contexts.
A suite is a collection of contexts. A suite stores its contexts in a single directory, and creates wrapper scripts for each tool in each context, which it stores into a single bin directory. When a tool is invoked, it executes the actual tool in its associated context. When you add a suite’s bin directory to PATH, you have access to all these tools, which will automatically run in correctly configured environments.
Tool clashes can occur when a tool of the same name is present in more than one context. When a context is added to a suite, or prefixed/suffixed, that context’s tools override tools from other contexts.
There are several ways to avoid tool name clashes: - Hide a tool. This removes it from the suite even if it does not clash; - Prefix/suffix a context. When you do this, all the tools in the context
have the prefix/suffix applied;
Explicitly alias a tool using the alias_tool method. This takes precedence over context prefix/suffixing.
- activation_shell_code(shell=None)[source]
Get shell code that should be run to activate this suite.
- add_context(name, context, prefix_char=None)[source]
Add a context to the suite.
- Parameters
name (str) – Name to store the context under.
context (ResolvedContext) – Context to add.
- alias_tool(context_name, tool_name, tool_alias)[source]
Register an alias for a specific tool.
Note that a tool alias takes precedence over a context prefix/suffix.
- context(name)[source]
Get a context.
- Parameters
name (str) – Name to store the context under.
- Returns
ResolvedContext object.
- property context_names
Get the names of the contexts in the suite.
- Reurns:
List of strings.
- find_contexts(in_request=None, in_resolve=None)[source]
Find contexts in the suite based on search criteria.
- Parameters
in_request (str) – Match contexts that contain the given package in their request.
in_resolve (str or Requirement) – Match contexts that contain the given package in their resolve. You can also supply a conflict requirement - ‘!foo’ will match any contexts whos resolve does not contain any version of package ‘foo’.
- Returns
List of context names that match the search criteria.
- get_alias_conflicts(tool_alias)[source]
Get a list of conflicts on the given tool alias.
- Parameters
tool_alias (str) – Alias to check for conflicts.
- Returns: None if the alias has no conflicts, or a list of dicts, where
each dict contains: - tool_name (str): The original, non-aliased name of the tool; - tool_alias (str): Aliased tool name (same as key); - context_name (str): Name of the context containing the tool; - variant (Variant): Variant providing the tool.
- get_conflicting_aliases()[source]
Get a list of tool aliases that have one or more conflicts.
- Returns
List of strings.
Get the tools hidden in this suite.
Hidden tools are those that have been explicitly hidden via hide_tool.
- Returns
tool_name (str): The original, non-aliased name of the tool;
tool_alias (str): Aliased tool name (same as key);
context_name (str): Name of the context containing the tool;
variant (Variant): Variant providing the tool.
- Return type
A list of dicts, where each dict contains
- get_tool_context(tool_alias)[source]
Given a visible tool alias, return the name of the context it belongs to.
- get_tool_filepath(tool_alias)[source]
Given a visible tool alias, return the full path to the executable.
- get_tools()[source]
Get the tools exposed by this suite.
- Returns
tool_name (str): The original, non-aliased name of the tool;
tool_alias (str): Aliased tool name (same as key);
context_name (str): Name of the context containing the tool;
variant (Variant or set): Variant providing the tool. If the tool is in conflict within the context (more than one package has a tool of the same name), this will be a set of Variants.
- Return type
A dict, keyed by aliased tool name, with dict entries
- classmethod load_visible_suites(paths=None)[source]
Get a list of suites whos bin paths are visible on $PATH.
- Returns
List of Suite objects.
- print_info(buf=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, verbose=False)[source]
Prints a message summarising the contents of the suite.
- print_tools(buf=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, verbose=False, context_name=None)[source]
Print table of tools available in the suite.
- Parameters
context_name (str) – If provided, only print the tools from this context.
- remove_context(name)[source]
Remove a context from the suite.
- Parameters
name (str) – Name of the context to remove.
- remove_context_prefix(name)[source]
Remove a context’s prefix.
- Parameters
name (str) – Name of the context to de-prefix.
- remove_context_suffix(name)[source]
Remove a context’s suffix.
- Parameters
name (str) – Name of the context to de-suffix.
- save(path, verbose=False)[source]
Save the suite to disk.
- Parameters
path (str) – Path to save the suite to. If a suite is already saved at path, then it will be overwritten. Otherwise, if path exists, an error is raised.
- set_context_prefix(name, prefix)[source]
Set a context’s prefix.
This will be applied to all wrappers for the tools in this context. For example, a tool called ‘foo’ would appear as ‘<prefix>foo’ in the suite’s bin path.
- set_context_suffix(name, suffix)[source]
Set a context’s suffix.
This will be applied to all wrappers for the tools in this context. For example, a tool called ‘foo’ would appear as ‘foo<suffix>’ in the suite’s bin path.
- tools_path
Simple property caching descriptor.
Example
>>> class Foo(object): >>> @cached_property >>> def bah(self): >>> print('bah') >>> return 1 >>> >>> f = Foo() >>> f.bah bah 1 >>> f.bah 1