rez.package_search#
Default algorithms for searching for packages based on some criteria. Package repository plugins may implement these algorithms instead, because they may be able to search packages much faster - for example, in a database-based package repository. The algorithms here serve as backup for those package repositories that do not provide an implementation.
- rez.package_search.get_reverse_dependency_tree(package_name, depth=None, paths=None, build_requires=False, private_build_requires=False)#
Find packages that depend on the given package.
This is a reverse dependency lookup. A tree is constructed, showing what packages depend on the given package, with an optional depth limit. A resolve does not occur. Only the latest version of each package is used, and requirements from all variants of that package are used.
- Parameters:
package_name (str) – Name of the package depended on.
depth (int) – Tree depth limit, unlimited if None.
paths (list of str) – paths to search for packages, defaults to config.packages_path.
build_requires (bool) – If True, includes packages’ build_requires.
private_build_requires (bool) – If True, include package_name’s private_build_requires.
- Returns:
A 2-tuple:
(list of list of str): Lists of package names, where each list is a single depth in the tree. The first list is always [package_name].
pygraph.digraph object, where nodes are package names, and package_name is always the leaf node.
- Return type:
- rez.package_search.get_plugins(package_name, paths=None)#
Find packages that are plugins of the given package.
- class rez.package_search.ResourceSearchResult#
Bases:
object
Items from a search.
Will contain either a package, variant, or name of a package family (str).
- __init__(resource, resource_type, validation_error=None)#
- class rez.package_search.ResourceSearcher#
Bases:
object
Search for resources (packages, variants or package families).
- __init__(package_paths=None, resource_type=None, no_local=False, latest=False, after_time=None, before_time=None, validate=False)#
Create resource search.
- Parameters:
resource_type (str) – type of resource to search for. One of “family”, “package” or “variant”. If None, is determined based on format of resources_request.
no_local (bool) – Do not look in local paths
latest (bool) – Only return latest version if resource type is package or variant
after_time (int) – Only show packages released after the given epoch time
before_time (int) – Only show packages released before the given epoch time
validate (bool) – Validate each resource that is found. If False, results are not validated (ie, validation_error is None).
- Returns:
List of ResourceSearchResult objects
- iter_resources(resources_request=None)#
Iterate over matching resources.
- Parameters:
resources_request (str) – Resource to search, glob-style patterns are supported. If None, returns all matching resource types.
- Returns:
2-tuple:
str: resource type (family, package, variant);
Iterator of ResourceSearchResult: Matching resources. Will be in alphabetical order if families, and version ascending for packages or variants.
- Return type:
- search(resources_request=None)#
Search for resources.
- Parameters:
resources_request (str) – Resource to search, glob-style patterns are supported. If None, returns all matching resource types.
- Returns:
2-tuple:
str: resource type (family, package, variant);
List of ResourceSearchResult: Matching resources. Will be in alphabetical order if families, and version ascending for packages or variants.
- Return type:
- class rez.package_search.ResourceSearchResultFormatter#
Bases:
object
Formats search results.
- fields = ('pre_commands', 'tools', 'uuid', 'build_requires', 'version', 'timestamp', 'release_message', 'private_build_requires', 'revision', 'description', 'base', 'authors', 'variants', 'commands', 'name', 'changelog', 'post_commands', 'requires', 'root', 'index', 'uri', 'num_variants', 'qualified_name')#
- __init__(output_format=None, suppress_newlines=False)#
- Parameters:
output_format (str) – String that can contain keywords such as “{base}”. These (or their appreviations) will be expanded into the matching resource attribute, or left unexpanded if the attribute does not exist. The ‘n’ literal will be converted into newlines. Defaults to qualified name.
suppress_newlines (bool) – If True, replace newlines with ‘n’.
- print_search_results(search_results, buf=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)#
Print formatted search results.
- Parameters:
search_results (list of ResourceSearchResult) – Search to format.