rez.packages
- class rez.packages.Package(resource, context=None)[source]
Bases:
rez.packages.PackageBaseResourceWrapperA package.
Note
Do not instantiate this class directly, instead use the function iter_packages or PackageFamily.iter_packages.
- arbitrary_keys()[source]
Get the arbitrary keys present in this package.
These are any keys not in the standard list (‘name’, ‘version’ etc).
- Returns
Arbitrary keys.
- Return type
set of str
- as_exact_requirement()[source]
Get the package, as an exact requirement string.
- Returns
Equivalent requirement string, eg “maya==2016.1”
- property authors
- property base
- property build_requires
- property cachable
- property changelog
- property commands
- property description
- get_variant(index=None)[source]
Get the variant with the associated index.
- Returns
Variant object, or None if no variant with the given index exists.
- property has_plugins
- property hashed_variants
- property help
- property is_cachable
True if the package and its payload is safe to cache locally.
- is_package = True
- property is_relocatable
True if the package and its payload is safe to copy.
- is_variant = False
- iter_variants()[source]
Iterate over the variants within this package, in index order.
- Returns
Variant iterator.
- keys = {'authors', 'base', 'build_requires', 'cachable', 'changelog', 'commands', 'config', 'description', 'has_plugins', 'hashed_variants', 'help', 'name', 'plugin_for', 'post_commands', 'pre_build_commands', 'pre_commands', 'pre_test_commands', 'previous_revision', 'previous_version', 'private_build_requires', 'release_message', 'relocatable', 'requires', 'revision', 'tests', 'timestamp', 'tools', 'uuid', 'variants', 'vcs', 'version'}
- property name
- num_variants
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
- parent
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
- property plugin_for
- property post_commands
- property pre_build_commands
- property pre_commands
- property pre_test_commands
- property previous_revision
- property previous_version
- property private_build_requires
- qualified_name
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
- property release_message
- property relocatable
- property requires
- property revision
- property tests
- property timestamp
- property tools
- property uuid
- property variants
- property vcs
- property version
- class rez.packages.PackageBaseResourceWrapper(resource, context=None)[source]
Bases:
rez.packages.PackageRepositoryResourceWrapperAbstract base class for Package and Variant.
- property config
Returns the config for this package.
Defaults to global config if this package did not provide a ‘config’ section.
- is_local
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
- late_bind_schemas = {'requires': Schema([Or(<class 'rez.utils.formatting.PackageRequest'>, And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>)))])}
- print_info(buf=None, format_=<FileFormat.yaml: ('yaml', )>, skip_attributes=None, include_release=False)[source]
Print the contents of the package.
- Parameters
buf (file-like object) – Stream to write to.
format (FileFormat) – Format to write in.
skip_attributes (list of str) – List of attributes to not print.
include_release (bool) – If True, include release-related attributes, such as ‘timestamp’ and ‘changelog’
- property uri
- class rez.packages.PackageFamily(resource)[source]
Bases:
rez.packages.PackageRepositoryResourceWrapperA package family.
Note
Do not instantiate this class directly, instead use the function iter_package_families.
- iter_packages()[source]
Iterate over the packages within this family, in no particular order.
- Returns
Package iterator.
- keys = {'name'}
- property name
- class rez.packages.PackageRepositoryResourceWrapper(resource)[source]
Bases:
rez.utils.resources.ResourceWrapper,rez.utils.formatting.StringFormatMixin- format_expand = <StringFormatType.unchanged: 3>
- property repository
The package repository this resource comes from.
- Returns
PackageRepository.
- class rez.packages.PackageSearchPath(packages_path)[source]
Bases:
objectA list of package repositories.
For example, $REZ_PACKAGES_PATH refers to a list of repositories.
- class rez.packages.Variant(resource, context=None, parent=None)[source]
Bases:
rez.packages.PackageBaseResourceWrapperA package variant.
Note
Do not instantiate this class directly, instead use the function Package.iter_variants.
- property authors
- property base
- property build_requires
- property cachable
- property changelog
- property commands
- property description
- get_requires(build_requires=False, private_build_requires=False)[source]
Get the requirements of the variant.
- property has_plugins
- property hashed_variants
- property help
- property index
- install(path, dry_run=False, overrides=None)[source]
Install this variant into another package repository.
If the package already exists, this variant will be correctly merged into the package. If the variant already exists in this package, the existing variant is returned.
- Parameters
path (str) – Path to destination package repository.
dry_run (bool) – If True, do not actually install the variant. In this mode, a Variant instance is only returned if the equivalent variant already exists in this repository; otherwise, None is returned.
overrides (dict) – Use this to change or add attributes to the installed variant.
- Returns
Variant object - the (existing or newly created) variant in the specified repository. If dry_run is True, None may be returned.
- is_package = False
- is_variant = True
- keys = {'authors', 'base', 'build_requires', 'cachable', 'changelog', 'commands', 'config', 'description', 'has_plugins', 'hashed_variants', 'help', 'index', 'name', 'plugin_for', 'post_commands', 'pre_build_commands', 'pre_commands', 'pre_test_commands', 'previous_revision', 'previous_version', 'private_build_requires', 'release_message', 'relocatable', 'requires', 'revision', 'root', 'subpath', 'tests', 'timestamp', 'tools', 'uuid', 'vcs', 'version'}
- property name
- parent
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
- property plugin_for
- property post_commands
- property pre_build_commands
- property pre_commands
- property pre_test_commands
- property previous_revision
- property previous_version
- property private_build_requires
- qualified_name
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
- qualified_package_name
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
- property release_message
- property relocatable
- property requires
Get variant requirements.
This is a concatenation of the package requirements and those of this specific variant.
- Returns
List of Requirement objects.
- property revision
- property root
- property subpath
- property tests
- property timestamp
- property tools
- property uuid
- property variant_requires
Get the subset of requirements specific to this variant.
- Returns
List of Requirement objects.
- property vcs
- property version
- rez.packages.create_package(name, data, package_cls=None)[source]
Create a package given package data.
- rez.packages.get_completions(prefix, paths=None, family_only=False)[source]
Get autocompletion options given a prefix string.
Example
>>> get_completions("may") set(["maya", "maya_utils"]) >>> get_completions("maya-") set(["maya-2013.1", "maya-2015.0.sp1"])
- rez.packages.get_last_release_time(name, paths=None)[source]
Returns the most recent time this package was released.
Note that releasing a variant into an already-released package is also considered a package release.
- rez.packages.get_latest_package(name, range_=None, paths=None, error=False)[source]
Get the latest package for a given package name.
- Parameters
- Returns
Package object, or None if no package is found.
- rez.packages.get_latest_package_from_string(txt, paths=None, error=False)[source]
Get the latest package found within the given request string.
- rez.packages.get_package(name, version, paths=None)[source]
Get a package by searching a list of repositories.
- rez.packages.get_package_family_from_repository(name, path)[source]
Get a package family from a repository.
- Parameters
name (str) – Name of the package, eg ‘maya’.
- Returns
PackageFamily object, or None if the family was not found.
- rez.packages.get_package_from_handle(package_handle)[source]
Create a package given its handle (or serialized dict equivalent)
- Parameters
package_handle (ResourceHandle or dict) – Resource handle, or equivalent serialized dict representation from ResourceHandle.to_dict
- Returns
Package.
- rez.packages.get_package_from_repository(name, version, path)[source]
Get a package from a repository.
- rez.packages.get_package_from_string(txt, paths=None)[source]
Get a package given a string.
- Parameters
txt (str) – String such as ‘foo’, ‘bah-1.3’.
paths (list of str, optional) – paths to search for package, defaults to config.packages_path.
- Returns
Package instance, or None if no package was found.
- rez.packages.get_package_from_uri(uri, paths=None)[source]
Get a package given its URI.
- Parameters
uri (str) – Variant URI
paths (list of str) – paths to search for packages, defaults to config.packages_path. If None, attempts to find a package that may have come from any package repo.
- Returns
Package, or None if the package could not be found.
- rez.packages.get_variant(variant_handle, context=None)[source]
Create a variant given its handle (or serialized dict equivalent)
- Parameters
variant_handle (ResourceHandle or dict) – Resource handle, or equivalent serialized dict representation from ResourceHandle.to_dict
context (ResolvedContext) – The context this variant is associated with, if any.
- Returns
Variant.
- rez.packages.get_variant_from_uri(uri, paths=None)[source]
Get a variant given its URI.
- Parameters
uri (str) – Variant URI
paths (list of str) – paths to search for variants, defaults to config.packages_path. If None, attempts to find a variant that may have come from any package repo.
- Returns
Variant, or None if the variant could not be found.
- rez.packages.iter_package_families(paths=None)[source]
Iterate over package families, in no particular order.
Note that multiple package families with the same name can be returned. Unlike packages, families later in the searchpath are not hidden by earlier families.
- Parameters
paths (list of str, optional) – paths to search for package families, defaults to config.packages_path.
- Returns
PackageFamily iterator.
- rez.packages.iter_packages(name, range_=None, paths=None)[source]
Iterate over Package instances, in no particular order.
Packages of the same name and version earlier in the search path take precedence - equivalent packages later in the paths are ignored. Packages are not returned in any specific order.