rezplugins.package_repository.memory¶
In-memory package repository
- class rezplugins.package_repository.memory.MemoryPackageFamilyResource¶
Bases:
PackageFamilyResource- key = 'memory.family'¶
Unique identifier of the resource type.
- repository_type = 'memory'¶
Type of package repository associated with this resource type.
- iter_packages() Iterator[MemoryPackageResource]¶
- handle() ResourceHandle¶
Get the resource handle.
- classmethod normalize_variables(variables)¶
Give subclasses a chance to standardize values for certain variables
- schema = None¶
Schema for the resource data. Must validate a dict. Can be None, in which case the resource does not load any data.
- schema_error¶
alias of
PackageMetadataError
- class rezplugins.package_repository.memory.MemoryPackageResource¶
Bases:
PackageResourceHelper- key = 'memory.package'¶
Unique identifier of the resource type.
- variant_key = 'memory.variant'¶
- repository_type = 'memory'¶
Type of package repository associated with this resource type.
- schema = Schema({Schema('name'): <class 'str'>, Optional('base'): <class 'str'>, Optional('version'): And(<class 'str'>, Use(<class 'rez.version._version.Version'>)), Optional('description'): And(<class 'str'>, Use(<function <lambda>>)), Optional('authors'): [<class 'str'>], Optional('requires'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>))]), Optional('build_requires'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>))]), Optional('private_build_requires'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>))]), Optional('variants'): [[And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>))]], Optional('has_plugins'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <class 'bool'>), Optional('plugin_for'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'str'>]), Optional('uuid'): <class 'str'>, Optional('config'): And(<class 'dict'>, Use(<function <lambda>>)), Optional('tools'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'str'>]), Optional('help'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Or(<class 'str'>, [[<class 'str'>]])), Optional('hashed_variants'): <class 'bool'>, Optional('relocatable'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Or(None, <class 'bool'>)), Optional('cachable'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Or(None, <class 'bool'>)), Optional('tests'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Schema({Optional(<class 'str'>): Or(Or(<class 'str'>, [<class 'str'>]), {Optional(<class 'str'>): <class 'object'>, 'command': Or(<class 'str'>, [<class 'str'>]), Optional('requires'): [Or(<class 'rez.utils.formatting.PackageRequest'>, And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>)))], Optional('run_on'): Or(<class 'str'>, [<class 'str'>]), Optional('on_variants'): Or(<class 'bool'>, {'type': 'requires', 'value': [Or(<class 'rez.utils.formatting.PackageRequest'>, And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>)))]})})})), Optional('pre_commands'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <built-in function callable>, <class 'str'>, [<class 'str'>]), Optional('commands'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <built-in function callable>, <class 'str'>, [<class 'str'>]), Optional('post_commands'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <built-in function callable>, <class 'str'>, [<class 'str'>]), Optional('pre_build_commands'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <built-in function callable>, <class 'str'>, [<class 'str'>]), Optional('pre_test_commands'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <built-in function callable>, <class 'str'>, [<class 'str'>]), Optional('timestamp'): <class 'int'>, Optional('revision'): <class 'object'>, Optional('changelog'): And(<class 'str'>, Use(<function <lambda>>)), Optional('release_message'): Or(None, <class 'str'>), Optional('previous_version'): And(<class 'str'>, Use(<class 'rez.version._version.Version'>)), Optional('previous_revision'): <class 'object'>, Optional('vcs'): <class 'str'>, Optional(<class 'str'>): Or(<class 'rez.utils.sourcecode.SourceCode'>, <class 'object'>)})¶
Schema for the resource data. Must validate a dict. Can be None, in which case the resource does not load any data.
- parent() PackageRepositoryResource¶
- authors()¶
- build_requires()¶
- cachable()¶
- changelog()¶
- commands() SourceCode¶
- config()¶
- description()¶
- handle() ResourceHandle¶
Get the resource handle.
- has_plugins()¶
- hashed_variants()¶
- help()¶
- iter_variants() Iterator[VariantResourceHelper]¶
- classmethod normalize_variables(variables)¶
Make sure version is treated consistently
- plugin_for()¶
- post_commands() SourceCode¶
- pre_build_commands()¶
- pre_commands() SourceCode¶
- pre_test_commands()¶
- previous_revision()¶
- previous_version()¶
- private_build_requires()¶
- release_message()¶
- relocatable()¶
- requires()¶
- revision()¶
- schema_error¶
alias of
PackageMetadataError
- tests()¶
- timestamp()¶
- tools()¶
- uuid()¶
- validated_data()¶
- variants()¶
- vcs()¶
- class rezplugins.package_repository.memory.MemoryVariantResource¶
Bases:
VariantResourceHelper- key = 'memory.variant'¶
Unique identifier of the resource type.
- repository_type = 'memory'¶
Type of package repository associated with this resource type.
- parent() PackageRepositoryResource¶
- property authors¶
- property base¶
- property build_requires¶
- property cachable¶
- property changelog¶
- property commands¶
- property config¶
- property description¶
- handle() ResourceHandle¶
Get the resource handle.
- property has_plugins¶
- property hashed_variants¶
- property help¶
- 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', 'vcs', 'version'}¶
- classmethod normalize_variables(variables)¶
Make sure version is treated consistently
- 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¶
- property release_message¶
- property relocatable¶
- property requires¶
- property revision¶
- schema = Schema({Schema('name'): <class 'str'>, Optional('base'): <class 'str'>, Optional('version'): <class 'rez.version._version.Version'>, Optional('description'): <class 'str'>, Optional('authors'): [<class 'str'>], Optional('requires'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'rez.utils.formatting.PackageRequest'>]), Optional('build_requires'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'rez.utils.formatting.PackageRequest'>]), Optional('private_build_requires'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'rez.utils.formatting.PackageRequest'>]), Optional('has_plugins'): Or(<class 'rez.utils.sourcecode.SourceCode'>, <class 'bool'>), Optional('plugin_for'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'str'>]), Optional('uuid'): <class 'str'>, Optional('config'): <class 'rez.config.Config'>, Optional('tools'): Or(<class 'rez.utils.sourcecode.SourceCode'>, [<class 'str'>]), Optional('help'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Or(<class 'str'>, [[<class 'str'>]])), Optional('hashed_variants'): <class 'bool'>, Optional('relocatable'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Or(None, <class 'bool'>)), Optional('cachable'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Or(None, <class 'bool'>)), Optional('tests'): Or(<class 'rez.utils.sourcecode.SourceCode'>, Schema({Optional(<class 'str'>): Or(Or(<class 'str'>, [<class 'str'>]), {Optional(<class 'str'>): <class 'object'>, 'command': Or(<class 'str'>, [<class 'str'>]), Optional('requires'): [Or(<class 'rez.utils.formatting.PackageRequest'>, And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>)))], Optional('run_on'): Or(<class 'str'>, [<class 'str'>]), Optional('on_variants'): Or(<class 'bool'>, {'type': 'requires', 'value': [Or(<class 'rez.utils.formatting.PackageRequest'>, And(<class 'str'>, Use(<class 'rez.utils.formatting.PackageRequest'>)))]})})})), Optional('pre_commands'): <class 'rez.utils.sourcecode.SourceCode'>, Optional('commands'): <class 'rez.utils.sourcecode.SourceCode'>, Optional('post_commands'): <class 'rez.utils.sourcecode.SourceCode'>, Optional('pre_build_commands'): <class 'rez.utils.sourcecode.SourceCode'>, Optional('pre_test_commands'): <class 'rez.utils.sourcecode.SourceCode'>, Optional('timestamp'): <class 'int'>, Optional('revision'): <class 'object'>, Optional('changelog'): <class 'str'>, Optional('release_message'): Or(None, <class 'str'>), Optional('previous_version'): <class 'rez.version._version.Version'>, Optional('previous_revision'): <class 'object'>, Optional('vcs'): <class 'str'>, Optional(<class 'str'>): Or(<class 'rez.utils.sourcecode.SourceCode'>, <class 'object'>)})¶
Schema for the resource data. Must validate a dict. Can be None, in which case the resource does not load any data.
- schema_error¶
alias of
PackageMetadataError
- subpath() str¶
Return the variant’s ‘subpath’
The subpath is the relative path the variant’s payload should be stored under, relative to the package base. If None, implies that the variant root matches the package base.
- property tests¶
- property timestamp¶
- property tools¶
- property uuid¶
- validated_data()¶
- variant_requires() list[Requirement]¶
- property vcs¶
- property wrapped¶
- class rezplugins.package_repository.memory.MemoryPackageRepository¶
Bases:
PackageRepositoryAn in-memory package repository.
Packages are stored in a dict, organised like so:
{ "foo": { "1.0.0": { "name": "foo", "version": "1.0.0", "description": "does foo-like things." } }, "bah": { "_NO_VERSION": { "name": "bah", "description": "does bah-like things.", "requires": ["python-2.6", "foo-1+"] } } }
This example repository contains one versioned package ‘foo’, and one unversioned package ‘bah’.
- classmethod create_repository(repository_data) MemoryPackageRepository¶
Create a standalone, in-memory repository.
Using this function bypasses the
package_repository_managersingleton. This is usually desired however, since in-memory repositories are for temporarily storing programmatically created packages, which we do not want to cache and that do not persist.- Parameters:
repository_data (dict) – Repository data, see class docstring.
- Returns:
MemoryPackageRepository object.
- __init__(location: str, resource_pool: ResourcePool) None¶
Create an in-memory package repository.
- Parameters:
location (str) – Path containing the package repository.
- get_package_family(name: str) MemoryPackageFamilyResource | None¶
Get a package family.
- Parameters:
name – Package name.
- Returns:
PackageFamilyResource, or None if not found.
- iter_package_families() Iterator[MemoryPackageFamilyResource | None]¶
Iterate over the package families in the repository, in no particular order.
- Returns:
PackageFamilyResource iterator.
- iter_packages(package_family_resource: MemoryPackageFamilyResource) Iterator[MemoryPackageResource]¶
Iterate over the packages within the given family, in no particular order.
- Parameters:
package_family_resource – Parent family.
- Returns:
PackageResource iterator.
- iter_variants(package_resource: PackageResourceHelper) Iterator[VariantResource]¶
Iterate over the variants within the given package.
- Parameters:
package_resource – Parent package.
- Returns:
VariantResource iterator.
- get_parent_package_family(package_resource: PackageResourceHelper) PackageFamilyResource¶
Get the parent package family of the given package.
- Parameters:
package_resource – Package.
- Returns:
PackageFamilyResource.
- get_parent_package(variant_resource: VariantResource)¶
Get the parent package of the given variant.
- Parameters:
variant_resource – Variant.
- Returns:
PackageResource.
- get_equivalent_variant(variant_resource: VariantResource) VariantResource¶
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 – Variant to install.
- Returns:
VariantResource object, or None if the variant was not found.
- get_last_release_time(package_family_resource: PackageFamilyResource) int¶
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.
- get_package(name: str, version: Version) PackageResourceHelper | None¶
Get a package.
- Parameters:
name – Package name.
version – Package version.
- Returns:
Matching package, or None if not found.
- Return type:
PackageResourceHelper or None
- get_package_from_uri(uri: str) PackageResource | None¶
Get a package given its URI.
- Parameters:
uri – Package URI
- Returns:
PackageResource, or None if the package is not present in this package repository.
- get_package_payload_path(package_name: str, package_version: str | Version | None = None) str¶
Defines where a package’s payload should be installed to.
- Parameters:
package_name – Name of package.
package_version – Package version.
- Returns:
Path where package’s payload should be installed to.
- get_resource(resource_key: str | type[Resource], **variables: Any) Resource¶
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 – Name of the type of
Resourceto findvariables – data to identify / store on the resource
- Returns:
PackageRepositoryResource instance.
- get_resource_from_handle(resource_handle: ResourceHandle, verify_repo: bool = True) Resource¶
Get a resource from a handle.
- Parameters:
resource_handle – Handle of the resource.
- Returns:
PackageRepositoryResource instance.
- get_variant_from_uri(uri: str) VariantResource | None¶
Get a variant given its URI.
- Parameters:
uri – Variant URI
- Returns:
VariantResource, or None if the variant is not present in this package repository.
- get_variant_state_handle(variant_resource: PackageResource) Hashable | None¶
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: str, pkg_version: Version, allow_missing: bool = False) int¶
Ignore the given package.
Ignoring a package makes it invisible to further resolves.
- Parameters:
pkg_name – Package name
pkg_version – Package version
allow_missing – if True, allow for ignoring a package that does not exist. This is useful when you want to copy a package to a repo and you don’t want it visible until the copy is completed.
- Returns:
-1 if the package is not found, 0 if nothing was done (package already ignored) or 1 if package was ignored.
- install_variant(variant_resource: VariantResource, dry_run: bool = False, overrides: dict[str, Any] | None = None) VariantResource¶
Install a variant into this repository.
Use this function to install a variant from some other package repository into this one.
- Parameters:
variant_resource – Variant to install.
dry_run – If True, do not actually install the variant. In this mode, a
Variantinstance is only returned if the equivalent variant already exists in this repository; otherwise, None is returned.overrides – Use this to change or add attributes to the installed variant. To remove attributes, set values to
remove.
- Returns:
VariantResource object, which is the newly created variant in this repository. If
dry_runis True, None may be returned.
- is_empty() bool¶
Determine if the repository contains any packages.
- Returns:
True if there are no packages, False if there are at least one.
- make_resource_handle(resource_key: str, **variables: Any) ResourceHandle¶
Create a
ResourceHandleNearly all
ResourceHandlecreation 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: VariantResource) None¶
Called when a variant installation is cancelled.
This is called after
pre_variant_install(), but beforeinstall_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
BuildProcessto call this function at the appropriate time.
- pre_variant_install(variant_resource: VariantResource) None¶
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
BuildProcessto call this function at the appropriate time.
- register_resource(resource_class: type[Resource]) None¶
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>¶
see
install_variant().
- remove_ignored_since(days: int, dry_run: bool = False, verbose: bool = False) int¶
Remove packages ignored for >= specified number of days.
- Parameters:
days – Remove packages ignored >= this many days
dry_run – Dry run mode
verbose – Verbose mode
- Returns:
Number of packages removed. In dry-run mode, returns the number of packages that would be removed.
- remove_package(pkg_name: str, pkg_version: Version) bool¶
Remove a package.
Note that this should work even if the specified package is currently ignored.
- Parameters:
pkg_name – Package name
pkg_version – Package version
- Returns:
True if the package was removed, False if it wasn’t found.
- remove_package_family(pkg_name: str, force: bool = False) bool¶
Remove an empty package family.
- Parameters:
pkg_name – Package name
force – If True, delete even if not empty.
- Returns:
True if the family was removed, False if it wasn’t found.
- rezplugins.package_repository.memory.register_plugin()¶