rez.package_repository
- class rez.package_repository.PackageRepository(location, resource_pool)[source]
Bases:
objectBase class for package repositories implemented in the package_repository plugin type.
Note that, even though a package repository does determine where package payloads should go, it is not responsible for creating or copying these payloads.
- get_equivalent_variant(variant_resource)[source]
Find a variant in this repository that is equivalent to that given.
A variant is equivalent to another if it belongs to a package of the same name and version, and it has the same definition (ie package requirements).
Note that even though the implementation is trivial, this function is provided since using install_variant to find an existing variant is nonintuitive.
- Parameters
variant_resource (VariantResource) – Variant to install.
- Returns
VariantResource object, or None if the variant was not found.
- get_last_release_time(package_family_resource)[source]
Get the last time a package was added to the given family.
This information is used to cache resolves via memcached. It can be left not implemented, but resolve caching is a substantial optimisation that you will be missing out on.
- Returns
- Epoch time at which a package was changed/added/removed from
the given package family. Zero signifies an unknown last package update time.
- Return type
- get_package(name, version)[source]
Get a package.
- Parameters
name (str) – Package name.
version (Version) – Package version.
- Returns
Matching package, or None if not found.
- Return type
PackageResource or None
- get_package_family(name)[source]
Get a package family.
- Parameters
name (str) – Package name.
- Returns
PackageFamilyResource, or None if not found.
- get_package_from_uri(uri)[source]
Get a package given its URI.
- Parameters
uri (str) – Package URI
- Returns
PackageResource, or None if the package is not present in this package repository.
- get_package_payload_path(package_name, package_version=None)[source]
Defines where a package’s payload should be installed to.
- get_parent_package(variant_resource)[source]
Get the parent package of the given variant.
- Parameters
variant_resource (VariantResource) – Variant.
- Returns
PackageResource.
- get_parent_package_family(package_resource)[source]
Get the parent package family of the given package.
- Parameters
package_resource (PackageResource) – Package.
- Returns
PackageFamilyResource.
- get_resource(resource_key, **variables)[source]
Get a resource.
Attempts to get and return a cached version of the resource if available, otherwise a new resource object is created and returned.
- Parameters
resource_key (str) – Name of the type of Resources to find
variables – data to identify / store on the resource
- Returns
PackageRepositoryResource instance.
- get_resource_from_handle(resource_handle, verify_repo=True)[source]
Get a resource.
- Parameters
resource_handle (ResourceHandle) – Handle of the resource.
- Returns
PackageRepositoryResource instance.
- get_variant_from_uri(uri)[source]
Get a variant given its URI.
- Parameters
uri (str) – Variant URI
- Returns
VariantResource, or None if the variant is not present in this package repository.
- get_variant_state_handle(variant_resource)[source]
Get a value that indicates the state of the variant.
This is used for resolve caching. For example, in the ‘filesystem’ repository type, the ‘state’ is the last modified date of the file associated with the variant (perhaps a package.py). If the state of any variant has changed from a cached resolve - eg, if a file has been modified - the cached resolve is discarded.
This may not be applicable to your repository type, leave as-is if so.
- Returns
A hashable value.
- ignore_package(pkg_name, pkg_version, allow_missing=False)[source]
Ignore the given package.
Ignoring a package makes it invisible to further resolves.
- Parameters
- Returns
-1: Package not found
0: Nothing was done, package already ignored
1: Package was ignored
- Return type
- install_variant(variant_resource, dry_run=False, overrides=None)[source]
Install a variant into this repository.
Use this function to install a variant from some other package repository into this one.
- Parameters
variant_resource (VariantResource) – Variant to install.
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. To remove attributes, set values to PackageRepository.remove.
- Returns
VariantResource object, which is the newly created variant in this repository. If dry_run is True, None may be returned.
- is_empty()[source]
Determine if the repository contains any packages.
- Returns
True if there are no packages, False if there are at least one.
- iter_package_families()[source]
Iterate over the package families in the repository, in no particular order.
- Returns
PackageFamilyResource iterator.
- iter_packages(package_family_resource)[source]
Iterate over the packages within the given family, in no particular order.
- Parameters
package_family_resource (PackageFamilyResource) – Parent family.
- Returns
PackageResource iterator.
- iter_variants(package_resource)[source]
Iterate over the variants within the given package.
- Parameters
package_resource (PackageResource) – Parent package.
- Returns
VariantResource iterator.
- make_resource_handle(resource_key, **variables)[source]
Create a ResourceHandle
Nearly all ResourceHandle creation should go through here, because it gives the various resource classes a chance to normalize / standardize the resource handles, to improve caching / comparison / etc.
- on_variant_install_cancelled(variant_resource)[source]
Called when a variant installation is cancelled.
This is called after pre_variant_install, but before install_variant, which is not expected to be called.
Variant install cancellation usually happens for one of two reasons - either the variant installation failed (ie a build error occurred), or one or more of the package tests failed, aborting the installation.
Note that it is the responsibility of the BuildProcess to call this function at the appropriate time.
- pre_variant_install(variant_resource)[source]
Called before a variant is installed.
If any directories are created on disk for the variant to install into, this is called before that happens.
Note that it is the responsibility of the BuildProcess to call this function at the appropriate time.
- register_resource(resource_class)[source]
Register a resource with the repository.
Your derived repository class should call this method in its __init__ to register all the resource types associated with that plugin.
- remove = <object object>
- remove_ignored_since(days, dry_run=False, verbose=False)[source]
Remove packages ignored for >= specified number of days.
- remove_package(pkg_name, pkg_version)[source]
Remove a package.
Note that this should work even if the specified package is currently ignored.
- uid
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
- class rez.package_repository.PackageRepositoryGlobalStats[source]
Bases:
_thread._localGathers stats across package repositories.
- class rez.package_repository.PackageRepositoryManager(resource_pool=None)[source]
Bases:
objectPackage repository manager.
Manages retrieval of resources (packages and variants) from PackageRepository instances, and caches these resources in a resource pool.
- are_same(path_1, path_2)[source]
Test that path_1 and path_2 refer to the same repository.
This is more reliable than testing that the strings match, since slightly different strings might refer to the same repository (consider small differences in a filesystem path for example, eg ‘//svr/foo’, ‘/svr/foo’).
- Returns
True if the paths refer to the same repository, False otherwise.
- get_repository(path)[source]
Get a package repository.
- Parameters
path (str) – Entry from the ‘packages_path’ config setting. This may simply be a path (which is managed by the ‘filesystem’ package repository plugin), or a string in the form “type@location”, where ‘type’ identifies the repository plugin type to use.
- Returns
PackageRepository instance.
- get_resource(resource_key, repository_type, location, **variables)[source]
Get a resource.
Attempts to get and return a cached version of the resource if available, otherwise a new resource object is created and returned.
- Parameters
resource_key (str) – Name of the type of Resources to find
repository_type (str) – What sort of repository to look for the resource in
location (str) – location for the repository
variables – data to identify / store on the resource
- Returns
PackageRepositoryResource instance.
- rez.package_repository.create_memory_package_repository(repository_data)[source]
Create a standalone in-memory package repository from the data given.
See rezplugins/package_repository/memory.py for more details.
- Parameters
repository_data (dict) – Package repository data.
- Returns
PackageRepository object.