rez.suite¶
- class rez.suite.Tool¶
Bases:
TypedDict- variant: 'Variant | set[Variant]'¶
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class rez.suite.Context¶
Bases:
TypedDict- context: ResolvedContext¶
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class rez.suite.Suite¶
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.
- property context_names: list[str]¶
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: str, context: ResolvedContext, 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: str) None¶
Remove a context from the suite.
- Parameters:
name (str) – Name of the context to remove.
- set_context_prefix(name, prefix) None¶
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) None¶
Remove a context’s prefix.
- Parameters:
name (str) – Name of the context to de-prefix.
- set_context_suffix(name, suffix) None¶
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) None¶
Remove a context’s suffix.
- Parameters:
name (str) – Name of the context to de-suffix.
- unhide_tool(context_name, tool_name) None¶
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.
- 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: str) str | None¶
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() list[str]¶
Get a list of tool aliases that have one or more conflicts.
- Returns:
List of strings.
- get_alias_conflicts(tool_alias: str) list[Tool] | None¶
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.
- to_dict()¶
- save(path, verbose: bool = 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 visible_suite_paths(paths: list[str] | None = None)¶
Get a list of paths to suites that are visible on $PATH.
- Returns:
List of str.
- classmethod load_visible_suites(paths: list[str] | None = None) list[Suite]¶
Get a list of suites whos bin paths are visible on $PATH.
- Returns:
List of Suite objects.