rez.suite#
- class rez.suite.Suite#
Bases:
object
A 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.
- __init__()#
Create a suite.
- property context_names#
Get the names of the contexts in the suite.
- Reurns:
List of strings.
- tools_path()#
Get the path that should be added to $PATH to expose this suite’s tools.
- Returns:
Absolute path as a string, or None if this suite was not loaded from disk.
- activation_shell_code(shell=None)#
Get shell code that should be run to activate this suite.
- context(name)#
Get a context.
- Parameters:
name (str) – Name to store the context under.
- Returns:
ResolvedContext object.
- add_context(name, context, prefix_char=None)#
Add a context to the suite.
- Parameters:
name (str) – Name to store the context under.
context (ResolvedContext) – Context to add.
- find_contexts(in_request=None, in_resolve=None)#
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.
- remove_context(name)#
Remove a context from the suite.
- Parameters:
name (str) – Name of the context to remove.
- set_context_prefix(name, prefix)#
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.
- remove_context_prefix(name)#
Remove a context’s prefix.
- Parameters:
name (str) – Name of the context to de-prefix.
- set_context_suffix(name, suffix)#
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.
- remove_context_suffix(name)#
Remove a context’s suffix.
- Parameters:
name (str) – Name of the context to de-suffix.
- bump_context(name)#
Causes the context’s tools to take priority over all others.
- hide_tool(context_name, tool_name)#
Hide a tool so that it is not exposed in the suite.
- unhide_tool(context_name, tool_name)#
Unhide a tool so that it may be exposed in a suite.
Note that unhiding a tool doesn’t guarantee it can be seen - a tool of the same name from a different context may be overriding it.
- alias_tool(context_name, tool_name, tool_alias)#
Register an alias for a specific tool.
Note that a tool alias takes precedence over a context prefix/suffix.
- unalias_tool(context_name, tool_name)#
Deregister an alias for a specific tool.
- get_tools()#
Get the tools exposed by this suite.
- Returns:
A dict, keyed by aliased tool name, with dict entries:
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:
- get_tool_filepath(tool_alias)#
Given a visible tool alias, return the full path to the executable.
- get_tool_context(tool_alias)#
Given a visible tool alias, return the name of the context it belongs to.
Get the tools hidden in this suite.
Hidden tools are those that have been explicitly hidden via hide_tool.
- get_conflicting_aliases()#
Get a list of tool aliases that have one or more conflicts.
- Returns:
List of strings.
- get_alias_conflicts(tool_alias)#
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.
- validate()#
Validate the suite.
- to_dict()#
- classmethod from_dict(d)#
- save(path, verbose=False)#
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.
- classmethod load(path)#
- classmethod visible_suite_paths(paths=None)#
Get a list of paths to suites that are visible on $PATH.
- Returns:
List of str.
- classmethod load_visible_suites(paths=None)#
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)#
Prints a message summarising the contents of the suite.