1.1. Rez
1.1.1. Subpackages
- 1.1.1.1. rez._sys package
- 1.1.1.2. rez.bind package
- 1.1.1.3. rez.cli package
- 1.1.1.3.1. Submodules
- 1.1.1.3.2. rez.cli._bez module
- 1.1.1.3.3. rez.cli._main module
- 1.1.1.3.4. rez.cli._util module
- 1.1.1.3.5. rez.cli.bind module
- 1.1.1.3.6. rez.cli.bootstrap module
- 1.1.1.3.7. rez.cli.build module
- 1.1.1.3.8. rez.cli.context module
- 1.1.1.3.9. rez.cli.env module
- 1.1.1.3.10. rez.cli.forward module
- 1.1.1.3.11. rez.cli.interpret module
- 1.1.1.3.12. rez.cli.release module
- 1.1.1.3.13. rez.cli.settings module
- 1.1.1.3.14. rez.cli.suite module
- 1.1.1.3.15. rez.cli.test module
- 1.1.1.3.16. rez.cli.tools module
- 1.1.1.3.17. Module contents
- 1.1.1.4. rez.tests package
- 1.1.1.4.1. Submodules
- 1.1.1.4.2. rez.tests.test_build module
- 1.1.1.4.3. rez.tests.test_commands module
- 1.1.1.4.4. rez.tests.test_context module
- 1.1.1.4.5. rez.tests.test_formatter module
- 1.1.1.4.6. rez.tests.test_rex module
- 1.1.1.4.7. rez.tests.test_shells module
- 1.1.1.4.8. rez.tests.test_solver module
- 1.1.1.4.9. rez.tests.util module
- 1.1.1.4.10. Module contents
1.1.2. Submodules
1.1.3. rez.bind_utils module
1.1.4. rez.bootstrap module
1.1.5. rez.build_process module
- class rez.build_process.BuildProcess(working_dir, build_system, package=None, vcs=None, ensure_latest=True, skip_repo_errors=False, ignore_existing_tag=False, verbose=False, quiet=False)[source]
Bases:
object
A BuildProcess builds and possibly releases a package.
A build process iterates over the variants of a package, creates the correct build environment for each variant, builds that variant using a build system (or possibly creates a script so the user can do that independently), and then possibly releases the package with the nominated VCS. This is an abstract base class, you should use a BuildProcess subclass.
- build(install_path=None, clean=False, install=False, variants=None)[source]
Perform the build process.
Iterates over the package’s variants, resolves the environment for each, and runs the build system within each resolved environment.
- Parameters
install_path (str) – The package repository path to install the package to, if installing. If None, defaults to config.local_packages_path.
clean (bool) – If True, clear any previous build first. Otherwise, rebuild over the top of a previous build.
install (bool) – If True, install the build.
variants (list of int) – Indexes of variants to build, all if None.
- Raises
BuildError – If the build failed.
- Returns
Number of variants successfully built.
- Return type
- get_changelog()[source]
Get the changelog since last package release.
- Returns
Changelog.
- Return type
- property package
- release(release_message=None, variants=None)[source]
Perform the release process.
Iterates over the package’s variants, building and installing each into the release path determined by config.release_packages_path.
- Parameters
release_message (str) – Message to associate with the release.
variants (list of int) – Indexes of variants to release, all if None.
- Raises
ReleaseError – If the release failed.
- Returns
Number of variants successfully released.
- Return type
- property working_dir
- class rez.build_process.BuildProcessHelper(working_dir, build_system, package=None, vcs=None, ensure_latest=True, skip_repo_errors=False, ignore_existing_tag=False, verbose=False, quiet=False)[source]
Bases:
rez.build_process.BuildProcess
A BuildProcess base class with some useful functionality.
- create_build_context(variant, build_type, build_path)[source]
Create a context to build the variant within.
- get_changelog()[source]
Get the changelog since last package release.
- Returns
Changelog.
- Return type
- class rez.build_process.BuildType(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Enum to represent the type of build.
1.1.6. rez.build_system module
- class rez.build_system.BuildSystem(working_dir, opts=None, package=None, write_build_scripts=False, verbose=False, build_args=[], child_build_args=[])[source]
Bases:
object
A build system, such as cmake, make, Scons etc.
- classmethod add_pre_build_commands(executor, variant, build_type, install, build_path, install_path=None)[source]
Execute pre_build_commands function if present.
- classmethod add_standard_build_actions(executor, context, variant, build_type, install, build_path, install_path=None)[source]
Perform build actions common to every build system.
- classmethod bind_cli(parser, group)[source]
Expose parameters to an argparse.ArgumentParser that are specific to this build system.
- Parameters
parser (ArgumentParser) – Arg parser.
group (ArgumentGroup) – Arg parser group - you should add args to this, NOT to parser.
- build(context, variant, build_path, install_path, install=False, build_type=<BuildType.local: 0>)[source]
Implement this method to perform the actual build.
- Parameters
context – A ResolvedContext object that the build process must be executed within.
variant (Variant) – The variant being built.
build_path – Where to write temporary build files. May be absolute or relative to working_dir.
install_path (str) – The package repository path to install the package to, if installing. If None, defaults to config.local_packages_path.
install – If True, install the build.
build_type – A BuildType (i.e local or central).
- Returns
success: Bool indicating if the build was successful.
- extra_files: List of created files of interest, not including
build targets. A good example is the interpreted context file, usually named ‘build.rxt.sh’ or similar. These files should be located under build_path. Rez may install them for debugging purposes.
- build_env_script: If this instance was created with write_build_scripts
as True, then the build should generate a script which, when run by the user, places them in the build environment.
- Return type
A dict containing the following information
- classmethod child_build_system()[source]
Returns the child build system.
Some build systems, such as cmake, don’t build the source directly. Instead, they build an interim set of build scripts that are then consumed by a second build system (such as make). You should implement this method if that’s the case.
- Returns
Name of build system (corresponding to the plugin name) if this system has a child system, or None otherwise.
- rez.build_system.create_build_system(working_dir, buildsys_type=None, package=None, opts=None, write_build_scripts=False, verbose=False, build_args=[], child_build_args=[])[source]
Return a new build system that can build the source in working_dir.
- rez.build_system.get_buildsys_types()[source]
Returns the available build system implementations - cmake, make etc.
- rez.build_system.get_valid_build_systems(working_dir, package=None)[source]
Returns the build system classes that could build the source in given dir.
- Parameters
working_dir (str) – Dir containing the package definition and potentially build files.
package (Package) – Package to be built. This may or may not be needed to determine the build system. For eg, cmake just has to look for a CMakeLists.txt file, whereas the ‘build_command’ package field must be present for the ‘custom’ build system type.
- Returns
Valid build system class types.
- Return type
List of class
1.1.7. rez.build_utils module
1.1.8. rez.dot module
1.1.9. rez.env module
1.1.10. rez.exceptions module
Exceptions.
- exception rez.exceptions.BuildContextResolveError(context)[source]
Bases:
rez.exceptions.BuildError
Raised if unable to resolve the required context when creating the environment for a build process.
- exception rez.exceptions.BuildError(value=None)[source]
Bases:
rez.exceptions.RezError
Base class for any build-related error.
- exception rez.exceptions.BuildProcessError(value=None)[source]
Bases:
rez.exceptions.RezError
Base class for build process-related errors.
- exception rez.exceptions.BuildSystemError(value=None)[source]
Bases:
rez.exceptions.BuildError
Base class for buildsys-related errors.
- exception rez.exceptions.ConfigurationError(value=None)[source]
Bases:
rez.exceptions.RezError
A misconfiguration error.
- exception rez.exceptions.ContextBundleError(value=None)[source]
Bases:
rez.exceptions.RezError
There was a problem bundling a context.
- exception rez.exceptions.InvalidPackageError(value=None)[source]
Bases:
rez.exceptions.RezError
A special case exception used in package ‘preprocess function’.
- exception rez.exceptions.PackageCacheError(value=None)[source]
Bases:
rez.exceptions.RezError
There was an error related to a package cache.
- exception rez.exceptions.PackageCommandError(value=None)[source]
Bases:
rez.exceptions.RezError
There is an error in a command or list of commands
- exception rez.exceptions.PackageCopyError(value=None)[source]
Bases:
rez.exceptions.RezError
There was a problem copying a package.
- exception rez.exceptions.PackageFamilyNotFoundError(value=None)[source]
Bases:
rez.exceptions.RezError
A package could not be found on disk.
- exception rez.exceptions.PackageMetadataError(value=None, path=None, resource_key=None)[source]
Bases:
rez.exceptions.ResourceContentError
There is an error in a package’s definition file.
- type_name = 'package definition file'
- exception rez.exceptions.PackageMoveError(value=None)[source]
Bases:
rez.exceptions.RezError
There was a problem moving a package.
- exception rez.exceptions.PackageNotFoundError(value=None)[source]
Bases:
rez.exceptions.RezError
A package could not be found on disk.
- exception rez.exceptions.PackageRepositoryError(value=None)[source]
Bases:
rez.exceptions.RezError
Base class for package repository- related errors.
- exception rez.exceptions.PackageRequestError(value=None)[source]
Bases:
rez.exceptions.RezError
There is an error related to a package request.
- exception rez.exceptions.PackageTestError(value=None)[source]
Bases:
rez.exceptions.RezError
There was a problem running a package test.
- exception rez.exceptions.ReleaseError(value=None)[source]
Bases:
rez.exceptions.RezError
Any release-related error.
- exception rez.exceptions.ReleaseHookCancellingError(value=None)[source]
Bases:
rez.exceptions.RezError
A release hook error that asks to cancel the release as a result.
- exception rez.exceptions.ReleaseHookError(value=None)[source]
Bases:
rez.exceptions.RezError
Base class for release-hook- related errors.
- exception rez.exceptions.ReleaseVCSError(value=None)[source]
Bases:
rez.exceptions.ReleaseError
Base class for release VCS-related errors.
- exception rez.exceptions.ResolveError(value=None)[source]
Bases:
rez.exceptions.RezError
A resolve-related error.
- exception rez.exceptions.ResolvedContextError(value=None)[source]
Bases:
rez.exceptions.RezError
An error occurred in a resolved context.
- exception rez.exceptions.ResourceContentError(value=None, path=None, resource_key=None)[source]
Bases:
rez.exceptions.ResourceError
A resource contains incorrect data.
- type_name = 'resource file'
- exception rez.exceptions.ResourceError(value=None)[source]
Bases:
rez.exceptions.RezError
Resource-related exception base class.
- exception rez.exceptions.ResourceNotFoundError(value=None)[source]
Bases:
rez.exceptions.ResourceError
A resource could not be found.
- exception rez.exceptions.RexError(value=None)[source]
Bases:
rez.exceptions.RezError
There is an error in Rex code.
- exception rez.exceptions.RexStopError(value=None)[source]
Bases:
rez.exceptions.RexError
Special error raised when a package commands uses the ‘stop’ command.
- exception rez.exceptions.RexUndefinedVariableError(value=None)[source]
Bases:
rez.exceptions.RexError
There is a reference to an undefined variable.
- exception rez.exceptions.RezBindError(value=None)[source]
Bases:
rez.exceptions.RezError
A bind-related error.
- exception rez.exceptions.RezGuiQTImportError[source]
Bases:
ImportError
A special case - see cli/gui.py
- exception rez.exceptions.RezPluginError(value=None)[source]
Bases:
rez.exceptions.RezError
An error related to plugin or plugin load.
- exception rez.exceptions.RezSystemError(value=None)[source]
Bases:
rez.exceptions.RezError
Rez system/internal error.
- exception rez.exceptions.SuiteError(value=None)[source]
Bases:
rez.exceptions.RezError
Any suite-related error.
1.1.11. rez.formulae_manager module
1.1.12. rez.package_maker module
- class rez.package_maker.PackageMaker(name, data=None, package_cls=None)[source]
Bases:
rez.utils.data_utils.AttrDictWrapper
Utility class for creating packages.
- rez.package_maker.make_package(name, path, make_base=None, make_root=None, skip_existing=True, warn_on_skip=True)[source]
Make and install a package.
Example
>>> def make_root(variant, path): >>> os.symlink("/foo_payload/misc/python27", "ext") >>> >>> with make_package('foo', '/packages', make_root=make_root) as pkg: >>> pkg.version = '1.0.0' >>> pkg.description = 'does foo things' >>> pkg.requires = ['python-2.7']
- Parameters
name (str) – Package name.
path (str) – Package repository path to install package into.
make_base (callable) – Function that is used to create the package payload, if applicable.
make_root (callable) – Function that is used to create the package variant payloads, if applicable.
skip_existing (bool) – If True, detect if a variant already exists, and skip with a warning message if so.
warn_on_skip (bool) – If True, print warning when a variant is skipped.
- Yields
PackageMaker object.
Note
Both make_base and make_root are called once per variant install, and have the signature (variant, path).
Note
The ‘installed_variants’ attribute on the PackageMaker instance will be appended with variant(s) created by this function, if any.
1.1.13. rez.package_maker_ module
1.1.14. rez.packages module
- class rez.packages.Package(resource, context=None)[source]
Bases:
rez.packages.PackageBaseResourceWrapper
A 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.PackageRepositoryResourceWrapper
Abstract 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.PackageRepositoryResourceWrapper
A 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:
object
A 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.PackageBaseResourceWrapper
A 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.
1.1.15. rez.platform_ module
1.1.16. rez.plugin_managers module
Manages loading of all types of Rez plugins.
- class rez.plugin_managers.BuildProcessPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different build and release processes.
- type_name = 'build_process'
- class rez.plugin_managers.BuildSystemPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different build systems when building packages.
- type_name = 'build_system'
- class rez.plugin_managers.CommandPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different custom Rez applications/subcommands.
- type_name = 'command'
- class rez.plugin_managers.PackageRepositoryPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different package repositories for loading packages.
- type_name = 'package_repository'
- class rez.plugin_managers.ReleaseHookPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different version control systems when releasing packages.
- type_name = 'release_hook'
- class rez.plugin_managers.ReleaseVCSPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different version control systems when releasing packages.
- type_name = 'release_vcs'
- class rez.plugin_managers.RezPluginManager[source]
Bases:
object
Primary interface for working with registered plugins.
Custom plugins are organized under a python package named ‘rezplugins’. The direct sub-packages of ‘rezplugins’ are the plugin types supported by rez, and the modules below that are individual custom plugins extending that type.
For example, rez provides plugins of type ‘build_system’: ‘cmake’ and ‘make’:
rezplugins/ __init__.py build_system/ __init__.py cmake.py make.py ...
Here is an example of how to provide your own plugin. In the example, we’ll be adding a plugin for the SCons build system.
Create the ‘rezplugins/build_system’ directory structure, add the empty ‘__init__.py’ files, and then place your new ‘scons.py’ plugin module into the ‘build_system’ sub-package:
rezplugins/ __init__.py build_system/ __init__.py scons.py
Write your ‘scons.py’ plugin module, sub-classing your SConsBuildSystem class from rez.build_systems.BuildSystem base class.
At the bottom of the module add a register_plugin function that returns your plugin class:
def register_plugin(): return SConsBuildSystem
- 3 Set or append the rez config setting plugin_path to point to the
directory above your ‘rezplugins’ directory.
All ‘rezplugin’ packages found on the search path will all be merged into a single python package.
- Note:
Even though ‘rezplugins’ is a python package, your sparse copy of it should not be on the PYTHONPATH, just the REZ_PLUGIN_PATH. This is important because it ensures that rez’s copy of ‘rezplugins’ is always found first.
- create_instance(plugin_type, plugin_name, **instance_kwargs)[source]
Create and return an instance of the given plugin.
- get_failed_plugins(plugin_type)[source]
Return a list of plugins for the given type that failed to load.
- Returns
name (str): Name of the plugin. reason (str): Error message.
- Return type
List of 2-tuples
- get_plugin_class(plugin_type, plugin_name)[source]
Return the class registered under the given plugin name.
- get_plugin_config_data(plugin_type)[source]
Return the merged configuration data for the plugin type.
- get_plugin_module(plugin_type, plugin_name)[source]
Return the module defining the class registered under the given plugin name.
- get_plugins(plugin_type)[source]
Return a list of the registered names available for the given plugin type.
- rezplugins_module_paths
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.plugin_managers.RezPluginType[source]
Bases:
object
An abstract base class representing a single type of plugin.
‘type_name’ must correspond with one of the source directories found under the ‘plugins’ directory.
- config_schema
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
- create_instance(plugin, **instance_kwargs)[source]
Create and return an instance of the given plugin.
- type_name = None
- class rez.plugin_managers.ShellPluginType[source]
Bases:
rez.plugin_managers.RezPluginType
Support for different types of target shells, such as bash, tcsh.
- type_name = 'shell'
- rez.plugin_managers.extend_path(path, name)[source]
Extend a package’s path.
Intended use is to place the following code in a package’s __init__.py:
from pkgutil import extend_path __path__ = extend_path(__path__, __name__)
This will add to the package’s __path__ all subdirectories of directories on ‘config.plugin_path’ named after the package. This is useful if one wants to distribute different parts of a single logical package as multiple directories.
If the input path is not a list (as is the case for frozen packages) it is returned unchanged. The input path is not modified; an extended copy is returned. Items are only appended to the copy at the end.
It is assumed that ‘plugin_path’ is a sequence. Items of ‘plugin_path’ that are not (unicode or 8-bit) strings referring to existing directories are ignored. Unicode items of sys.path that cause errors when used as filenames may cause this function to raise an exception (in line with os.path.isdir() behavior).
1.1.17. rez.py_dist module
1.1.18. rez.release_hook module
- class rez.release_hook.ReleaseHook(source_path)[source]
Bases:
object
An object that allows for custom behaviour during releases.
A release hook provides methods that you implement to inject custom behaviour during parts of the release process. For example, the builtin ‘email’ hook sends a post-release email to a configured address.
- post_release(user, install_path, variants, release_message=None, changelog=None, previous_version=None, previous_revision=None, **kwargs)[source]
Post-release hook.
This is called after all package variants have been released.
- Parameters
user – Name of person who did the release.
install_path – Directory the package was installed into.
variants (list of Variant) – The variants that have been released.
release_message – User-supplied release message.
changelog – List of strings describing changes since last release.
previous_version – Version of previously-release package, None if no previous release.
previous_revision – Revision of previously-releaved package (type depends on repo - see ReleaseVCS.get_current_revision().
kwargs – Reserved.
- pre_build(user, install_path, variants=None, release_message=None, changelog=None, previous_version=None, previous_revision=None, **kwargs)[source]
Pre-build hook.
- Parameters
user – Name of person who did the release.
install_path – Directory the package was installed into.
variants – List of variant indices we are attempting to build, or None
release_message – User-supplied release message.
changelog – List of strings describing changes since last release.
previous_version – Version object - previously-release package, or None if no previous release.
previous_revision – Revision of previously-released package (type depends on repo - see ReleaseVCS.get_current_revision().
kwargs – Reserved.
Note
This method should raise a ReleaseHookCancellingError if the release process should be cancelled.
- pre_release(user, install_path, variants=None, release_message=None, changelog=None, previous_version=None, previous_revision=None, **kwargs)[source]
Pre-release hook.
This is called before any package variants are released.
- Parameters
user – Name of person who did the release.
install_path – Directory the package was installed into.
variants – List of variant indices we are attempting to release, or None
release_message – User-supplied release message.
changelog – List of strings describing changes since last release.
previous_version – Version object - previously-release package, or None if no previous release.
previous_revision – Revision of previously-releaved package (type depends on repo - see ReleaseVCS.get_current_revision().
kwargs – Reserved.
Note
This method should raise a ReleaseHookCancellingError if the release process should be cancelled.
- class rez.release_hook.ReleaseHookEvent(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Enum to help manage release hooks.
1.1.19. rez.release_vcs module
- class rez.release_vcs.ReleaseVCS(pkg_root, vcs_root=None)[source]
Bases:
object
A version control system (VCS) used to release Rez packages.
- create_release_tag(tag_name, message=None)[source]
Create a tag in the repo.
Create a tag in the repository representing the release of the given version.
- classmethod export(revision, path)[source]
Export the repository to the given path at the given revision.
Note
The directory at path must not exist, but the parent directory must exist.
- classmethod find_vcs_root(path)[source]
Try to find a version control root directory of this type for the given path.
If successful, returns (vcs_root, levels_up), where vcs_root is the path to the version control root directory it found, and levels_up is an integer indicating how many parent directories it had to search through to find it, where 0 means it was found in the indicated path, 1 means it was found in that path’s parent, etc. If not sucessful, returns None
- get_changelog(previous_revision=None, max_revisions=None)[source]
Get the changelog text since the given revision.
If previous_revision is not an ancestor (for example, the last release was from a different branch) you should still return a meaningful changelog - perhaps include a warning, and give changelog back to the last common ancestor.
- Parameters
previous_revision – The revision to give the changelog since. If
None –
changelog. (give the entire) –
- Returns
Changelog, as a string.
- get_current_revision()[source]
Get the current revision, this can be any type (str, dict etc) appropriate to your VCS implementation.
Note
You must ensure that a revision contains enough information to clone/export/checkout the repo elsewhere - otherwise you will not be able to implement export.
- classmethod is_valid_root(path)[source]
Return True if the given path is a valid root directory for this version control system.
Note that this is different than whether the path is under the control of this type of vcs; to answer that question, use find_vcs_root
- classmethod search_parents_for_root()[source]
Return True if this vcs type should check parent directories to find the root directory
1.1.20. rez.resolved_context module
- class rez.resolved_context.PatchLock(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Enum to represent the ‘lock type’ used when patching context objects.
- class rez.resolved_context.ResolvedContext(package_requests, verbosity=0, timestamp=None, building=False, caching=None, package_paths=None, package_filter=None, package_orderers=None, max_fails=- 1, add_implicit_packages=True, time_limit=- 1, callback=None, package_load_callback=None, buf=None, suppress_passive=False, print_stats=False, package_caching=None)[source]
Bases:
object
A class that resolves, stores and spawns Rez environments.
The main Rez entry point for creating, saving, loading and executing resolved environments. A ResolvedContext object can be saved to file and loaded at a later date, and it can reconstruct the equivalent environment at that time. It can spawn interactive and non-interactive shells, in any supported shell plugin type, such as bash and tcsh. It can also run a command within a configured python namespace, without spawning a child shell.
- apply(parent_environ=None)[source]
Apply the context to the current python session.
Note that this updates os.environ and possibly sys.path, if parent_environ is not provided.
- Parameters
parent_environ – Environment to interpret the context within, defaults to os.environ if None.
- context_tracking_lock = <unlocked _thread.lock object>
- context_tracking_payload = None
- execute_command(args, parent_environ=None, **Popen_args)[source]
Run a command within a resolved context.
This applies the context to a python environ dict, then runs a subprocess in that namespace. This is not a fully configured subshell - shell-specific commands such as aliases will not be applied. To execute a command within a subshell instead, use execute_shell().
Warning
This runs a command in a configured environ dict only, not in a true shell. To do that, call execute_shell using the command keyword argument.
- Parameters
args – Command arguments, can be a string.
parent_environ – Environment to interpret the context within, defaults to os.environ if None.
Popen_args – Args to pass to subprocess.Popen.
- Returns
A subprocess.Popen object.
Note
This does not alter the current python session.
- execute_rex_code(code, filename=None, shell=None, parent_environ=None, **Popen_args)[source]
Run some rex code in the context.
Note
This is just a convenience form of execute_shell.
- Parameters
code (str) – Rex code to execute.
filename (str) – Filename to report if there are syntax errors.
shell – Shell type, for eg ‘bash’. If None, the current shell type is used.
parent_environ – Environment to run the shell process in, if None then the current environment is used.
Popen_args – args to pass to the shell process object constructor.
- Returns
subprocess.Popen object for the shell process.
- execute_shell(shell=None, parent_environ=None, rcfile=None, norc=False, stdin=False, command=None, quiet=False, block=None, actions_callback=None, post_actions_callback=None, context_filepath=None, start_new_session=False, detached=False, pre_command=None, **Popen_args)[source]
Spawn a possibly-interactive shell.
- Parameters
shell – Shell type, for eg ‘bash’. If None, the current shell type is used.
parent_environ – Environment to run the shell process in, if None then the current environment is used.
rcfile – Specify a file to source instead of shell startup files.
norc – If True, skip shell startup files, if possible.
stdin – If True, read commands from stdin, in a non-interactive shell.
command – If not None, execute this command in a non-interactive shell. If an empty string or list, don’t run a command, but don’t open an interactive shell either. Can be a list of args.
quiet – If True, skip the welcome message in interactive shells.
block – If True, block until the shell is terminated. If False, return immediately. If None, will default to blocking if the shell is interactive.
actions_callback – Callback with signature (RexExecutor). This lets the user append custom actions to the context, such as setting extra environment variables. Callback is run prior to context Rex execution.
post_actions_callback – Callback with signature (RexExecutor). This lets the user append custom actions to the context, such as setting extra environment variables. Callback is run after context Rex execution.
context_filepath – If provided, the context file will be written here, rather than to the default location (which is in a tempdir). If you use this arg, you are responsible for cleaning up the file.
start_new_session – If True, change the process group of the target process. Note that this may override the Popen_args keyword ‘preexec_fn’.
detached – If True, open a separate terminal. Note that this may override the pre_command argument.
pre_command – Command to inject before the shell command itself. This is for internal use.
Popen_args – args to pass to the shell process object constructor.
- Returns
A 3-tuple of (returncode, stdout, stderr); If non-blocking - A subprocess.Popen object for the shell process.
- Return type
If blocking
- get_actions(parent_environ=None)[source]
Get the list of rex.Action objects resulting from interpreting this context. This is provided mainly for testing purposes.
- Parameters
within (parent_environ Environment to interpret the context) – defaults to os.environ if None.
:param : defaults to os.environ if None.
- Returns
A list of rex.Action subclass instances.
- get_conflicting_tools(request_only=False)[source]
Returns tools of the same name provided by more than one package.
- Parameters
request_only – If True, only return the key from resolved packages that were also present in the request.
- Returns
set([Variant])}.
- Return type
Dict of {tool-name
- classmethod get_current()[source]
Get the context for the current env, if there is one.
- Returns
Current context, or None if not in a resolved env.
- Return type
ResolvedContext
- get_dependency_graph(as_dot=False)[source]
Generate the dependency graph.
The dependency graph is a simpler subset of the resolve graph. It contains package name nodes connected directly to their dependencies. Weak references and conflict requests are not included in the graph. The dependency graph does not show conflicts.
- Returns
pygraph.digraph object.
- get_environ(parent_environ=None)[source]
Get the environ dict resulting from interpreting this context.
- @param parent_environ Environment to interpret the context within,
defaults to os.environ if None.
- @returns The environment dict generated by this context, when
interpreted in a python rex interpreter.
- get_patched_request(package_requests=None, package_subtractions=None, strict=False, rank=0)[source]
Get a ‘patched’ request.
A patched request is a copy of this context’s request, but with some changes applied. This can then be used to create a new, ‘patched’ context.
New package requests override original requests based on the type - normal, conflict or weak. So ‘foo-2’ overrides ‘foo-1’, ‘!foo-2’ overrides ‘!foo-1’ and ‘~foo-2’ overrides ‘~foo-1’, but a request such as ‘!foo-2’ would not replace ‘foo-1’ - it would be added instead.
Note that requests in package_requests can have the form ‘^foo’. This is another way of supplying package subtractions.
Any new requests that don’t override original requests are appended, in the order that they appear in package_requests.
- Parameters
package_requests (list of str or list of PackageRequest) – Overriding requests.
package_subtractions (list of str) – Any original request with a package name in this list is removed, before the new requests are added.
strict (bool) – If True, the current context’s resolve is used as the original request list, rather than the request.
rank (int) – If > 1, package versions can only increase in this rank and further - for example, rank=3 means that only version patch numbers are allowed to increase, major and minor versions will not change. This is only applied to packages that have not been explicitly overridden in package_requests. If rank <= 1, or strict is True, rank is ignored.
- Returns
List of PackageRequest objects that can be used to construct a new ResolvedContext object.
- get_resolve_as_exact_requests()[source]
Convert to a package request list of exact resolved package versions.
>>> r = ResolvedContext(['foo'] >>> r.get_resolve_as_exact_requests() ['foo==1.2.3', 'bah==1.0.1', 'python==2.7.12']
- Returns
Context as a list of exact version requests.
- Return type
List of PackageRequest
- get_resolve_diff(other)[source]
Get the difference between the resolve in this context and another.
The difference is described from the point of view of the current context - a newer package means that the package in other is newer than the package in self.
Diffs can only be compared if their package search paths match, an error is raised otherwise.
The diff is expressed in packages, not variants - the specific variant of a package is ignored.
- Returns
‘newer_packages’: A dict containing items: - package name (str); - List of Package objects. These are the packages up to and
including the newer package in self, in ascending order.
’older_packages’: A dict containing: - package name (str); - List of Package objects. These are the packages down to and
including the older package in self, in descending order.
- ’added_packages’: Set of Package objects present in self but
not in other;
- ’removed_packages’: Set of Package objects present in other,
but not in self.
If any item (‘added_packages’ etc) is empty, it is not added to the resulting dict. Thus, an empty dict is returned if there is no difference between contexts.
- Return type
A dict containing
- get_resolved_package(name)[source]
Returns a Variant object or None if the package is not in the resolve.
- get_shell_code(shell=None, parent_environ=None, style=<OutputStyle.file: ('Code as it would appear in a script file.', )>)[source]
Get the shell code resulting from intepreting this context.
- get_tool_variants(tool_name)[source]
Get the variant(s) that provide the named tool.
If there are more than one variants, the tool is in conflict, and Rez does not know which variant’s tool is actually exposed.
- Parameters
tool_name (str) – Name of the tool to search for.
- Returns
Set of Variant objects. If no variant provides the tool, an empty set is returned.
- get_tools(request_only=False)[source]
Returns the commandline tools available in the context.
- Parameters
request_only – If True, only return the tools from resolved packages that were also present in the request.
- Returns
(variant, [tools])}.
- Return type
Dict of {pkg-name
- graph(as_dot=False)[source]
Get the resolve graph.
- Parameters
as_dot – If True, get the graph as a dot-language string. Otherwise, a pygraph.digraph object is returned.
- Returns
A string or pygraph.digraph object, or None if there is no graph associated with the resolve.
- property has_graph
Return True if the resolve has a graph.
- is_current()[source]
- Returns
True if this is the currently sourced context, False otherwise.
- Return type
- local = <_thread._local object>
- package_cache_present = True
- print_info(buf=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, verbosity=0, source_order=False, show_resolved_uris=False)[source]
Prints a message summarising the contents of the resolved context.
- Parameters
buf (file-like object) – Where to print this info to.
verbosity (bool) – Verbose mode.
source_order (bool) – If True, print resolved packages in the order they are sourced, rather than alphabetical order.
show_resolved_uris (bool) – By default, resolved packages have their ‘root’ property listed, or their ‘uri’ if ‘root’ is None. Use this option to list ‘uri’ regardless.
- print_resolve_diff(other, heading=None)[source]
Print the difference between the resolve of two contexts.
- Parameters
other (ResolvedContext) – Context to compare to.
heading –
One of: - None: Do not display a heading; - True: Display the filename of each context as a heading, if
both contexts have a filepath;
2-tuple: Use the given two strings as headings - the first is the heading for self, the second for other.
- requested_packages(include_implicit=False)[source]
Get packages in the request.
- Parameters
include_implicit (bool) – If True, implicit packages are appended to the result.
- Returns
List of PackageRequest objects.
- property resolved_ephemerals
Get non-conflict ephemerals in the resolve.
- Returns
List of Requirement objects, or None if the resolve failed.
- property resolved_packages
Get packages in the resolve.
- Returns
List of Variant objects, or None if the resolve failed.
- retargeted(package_paths, package_names=None, skip_missing=False)[source]
Create a retargeted copy of this context.
Retargeting a context means replacing its variant references with the same variants from other package repositories.
- Parameters
package_paths – List of paths to search for pkgs to retarget to.
package_names (list of str) – Only retarget these packages. If None, retarget all packages.
skip_missing (bool) – If True, skip retargeting of variants that cannot be found in package_paths. By default, a PackageNotFoundError is raised.
- Returns
The retargeted context.
- Return type
ResolvecContext`
- serialize_version = (4, 7)
- set_load_path(path)[source]
Set the path that this context was reportedly loaded from.
You may want to use this method in cases where a context is saved to disk, but you need to associate this new path with the context while it is still in use.
- property status
Return the current status of the context.
- Returns
ResolverStatus.
- property success
True if the context has been solved, False otherwise.
- tmpdir_manager = <rez.utils.filesystem.TempDirs object>
- to_dict(fields=None)[source]
Convert context to dict containing only builtin types.
- Parameters
fields (list of str) – If present, only write these fields into the dict. This can be used to avoid constructing expensive fields (such as ‘graph’) for some cases.
- Returns
Dictified context.
- Return type
- which(cmd, parent_environ=None, fallback=False)[source]
Find a program in the resolved environment.
- Parameters
cmd – String name of the program to find.
parent_environ – Environment to interpret the context within, defaults to os.environ if None.
fallback – If True, and the program is not found in the context, the current environment will then be searched.
- Returns
Path to the program, or None if the program was not found.
- class rez.resolved_context.RezToolsVisibility(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Determines if/how rez cli tools are added back to PATH within a resolved environment.
- class rez.resolved_context.SuiteVisibility(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Defines what suites on $PATH stay visible when a new rez environment is resolved.
- rez.resolved_context.get_lock_request(name, version, patch_lock, weak=True)[source]
Given a package and patch lock, return the equivalent request.
For example, for object ‘foo-1.2.1’ and lock type ‘lock_3’, the equivalent request is ‘~foo-1.2’. This restricts updates to foo to patch-or-lower version changes only.
For objects not versioned down to a given lock level, the closest possible lock is applied. So ‘lock_3’ applied to ‘foo-1’ would give ‘~foo-1’.
1.1.21. rez.resolver module
- class rez.resolver.Resolver(context, package_requests, package_paths, package_filter=None, package_orderers=None, timestamp=0, callback=None, building=False, verbosity=False, buf=None, package_load_callback=None, caching=True, suppress_passive=False, print_stats=False)[source]
Bases:
object
The package resolver.
The Resolver uses a combination of Solver(s) and cache(s) to resolve a package request as quickly as possible.
- property graph
Return the resolve graph.
The resolve graph shows unsuccessful as well as successful resolves.
- Returns
A pygraph.digraph object, or None if the solve has not completed.
- property resolved_ephemerals
Get the list of resolved ewphemerals.
- Returns
List of Requirement objects, or None if the resolve has not completed.
- property resolved_packages
Get the list of resolved packages.
- Returns
List of PackageVariant objects, or None if the resolve has not completed.
- property status
Return the current status of the resolve.
- Returns
ResolverStatus.
1.1.22. rez.resources module
1.1.23. rez.rex module
- class rez.rex.ActionInterpreter[source]
Bases:
object
Abstract base class that provides callbacks for rex Actions. This class should not be used directly. Its methods are called by the ActionManager in response to actions issued by user code written using the rex python API.
Sub-classes should override the get_output method to return implementation-specific data structure. For example, an interpreter for a shell language like bash would return a string of shell code. An interpreter for an active python session might return a dictionary of the modified environment.
Sub-classes can override the expand_env_vars class variable to instruct the ActionManager whether or not to expand the value of environment variables which reference other variables (e.g. “this-${THAT}”).
- ENV_VAR_REGEX = re.compile('\\${([^\\{\\}]+?)}|\\$([a-zA-Z_]+[a-zA-Z0-9_]*?)')
- appendenv(key, value)[source]
This is optional, but if it is not implemented, you must implement setenv.
- escape_string(value, is_path=False)[source]
Escape a string.
Escape the given string so that special characters (such as quotes and whitespace) are treated properly. If value is a string, assume that this is an expandable string in this interpreter.
Note that is_path provided because of the special case where a path-like envvar is set. In this case, path normalization, if it needs to occur, has to be part of the string escaping process.
Note
This default implementation returns the string with no escaping applied.
- expand_env_vars = False
- get_output(style=<OutputStyle.file: ('Code as it would appear in a script file.', )>)[source]
Returns any implementation specific data.
- Parameters
style (OutputStyle) – Style affecting output format.
- Returns
Depends on implementation, but usually a code string.
- normalize_path(path)[source]
Normalize a path.
Change path to a valid filepath representation for this interpreter.
IMPORTANT: Because var references like ${THIS} might be passed to funcs like appendvar, path might be in this form. You need to take that into account (ie, ensure normalization doesn’t break such a var reference).
- Parameters
path (str) – A filepath which may be in posix format, or windows format, or some combination of the two. For eg, a string like {root}/bin on windows will evaluate to C:.../bin - in this case, the cmd shell would want to normalize this and convert to all forward slashes.
- Returns
The normalized path.
- Return type
- normalize_paths(value)[source]
Normalize value if it’s a path(s).
Note that value may be more than one pathsep-delimited paths.
- pathsep = ':'
- class rez.rex.ActionManager(interpreter, parent_environ=None, parent_variables=None, formatter=None, verbose=False, env_sep_map=None)[source]
Bases:
object
Handles the execution book-keeping. Tracks env variable values, and triggers the callbacks of the ActionInterpreter.
- get_action_methods()[source]
return a list of methods on this class for executing actions. methods are return as a list of (name, func) tuples
- class rez.rex.Alias(*args)[source]
Bases:
rez.rex.Action
- name = 'alias'
- class rez.rex.Appendenv(*args)[source]
Bases:
rez.rex.Setenv
- name = 'appendenv'
- class rez.rex.Command(*args)[source]
Bases:
rez.rex.Action
- name = 'command'
- class rez.rex.Comment(*args)[source]
Bases:
rez.rex.Action
- name = 'comment'
- class rez.rex.EnvAction(*args)[source]
Bases:
rez.rex.Action
- property key
- property value
- class rez.rex.EnvironmentDict(manager)[source]
Bases:
collections.abc.MutableMapping
Provides a mapping interface to EnvironmentVariable instances, which provide an object-oriented interface for recording environment variable manipulations.
__getitem__ is always guaranteed to return an EnvironmentVariable instance: it will not raise a KeyError.
- class rez.rex.EnvironmentVariable(name, environ_map)[source]
Bases:
object
class representing an environment variable
combined with EnvironmentDict class, records changes to the environment
- property name
- class rez.rex.Error(*args)[source]
Bases:
rez.rex.Action
- name = 'error'
- class rez.rex.EscapedString(value, is_literal=False)[source]
Bases:
object
Class for constructing literal or expandable strings, or a combination of both.
This determines how a string is escaped in an interpreter. For example, the following rex commands may result in the bash code shown:
>>> env.FOO = literal('oh "noes"') >>> env.BAH = expandable('oh "noes"') export FOO='oh "noes"' export BAH="oh "noes""
You do not need to use expandable - a string by default is interpreted as expandable. However you can mix literals and expandables together, like so:
>>> env.FOO = literal("hello").expandable(" ${DUDE}") export FOO='hello'" ${DUDE}"
Shorthand methods e and l are also supplied, for better readability:
>>> env.FOO = literal("hello").e(" ${DUDE}").l(", and welcome!") export FOO='hello'" ${DUDE}"', and welcome!'
Note
you can use the literal and expandable free functions, rather than constructing a class instance directly.
- expanduser()[source]
Analogous to os.path.expanduser.
- Returns
EscapedString object with expanded ‘~’ references.
- class rez.rex.Info(*args)[source]
Bases:
rez.rex.Action
- name = 'info'
- class rez.rex.NamespaceFormatter(namespace)[source]
Bases:
string.Formatter
String formatter that, as well as expanding ‘{variable}’ strings, also protects environment variable references such as ${THIS} so they do not get expanded as though {THIS} is a formatting target. Also, environment variable references such as $THIS are converted to ${THIS}, which gives consistency across shells, and avoids some problems with non-curly-braced variables in some situations.
- class rez.rex.OutputStyle(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Enum to represent the style of code output when using Rex.
- class rez.rex.Prependenv(*args)[source]
Bases:
rez.rex.Setenv
- name = 'prependenv'
- class rez.rex.Python(target_environ=None, passive=False)[source]
Bases:
rez.rex.ActionInterpreter
Execute commands in the current python session
- appendenv(key, value)[source]
This is optional, but if it is not implemented, you must implement setenv.
- expand_env_vars = True
- get_output(style=<OutputStyle.file: ('Code as it would appear in a script file.', )>)[source]
Returns any implementation specific data.
- Parameters
style (OutputStyle) – Style affecting output format.
- Returns
Depends on implementation, but usually a code string.
- class rez.rex.Resetenv(*args)[source]
Bases:
rez.rex.EnvAction
- property friends
- name = 'resetenv'
- class rez.rex.RexExecutor(interpreter=None, globals_map=None, parent_environ=None, parent_variables=None, shebang=True, add_default_namespaces=True)[source]
Bases:
object
Runs an interpreter over code within the given namespace. You can also access namespaces and rex functions directly in the executor, like so:
RexExecutor ex() ex.setenv(‘FOO’, ‘BAH’) ex.env.FOO_SET = 1 ex.alias(‘foo’,’foo -l’)
- property actions
List of Action objects that will be executed.
- classmethod compile_code(code, filename=None, exec_namespace=None)[source]
Compile and possibly execute rex code.
- execute_code(code, filename=None, isolate=False)[source]
Execute code within the execution context.
- execute_function(func, *nargs, **kwargs)[source]
Execute a function object within the execution context. @returns The result of the function call.
- get_output(style=<OutputStyle.file: ('Code as it would appear in a script file.', )>)[source]
Returns the result of all previous calls to execute_code.
- property interpreter
- normalize_path(path)[source]
Normalize a path.
Note that in many interpreters this will be unchanged.
- Returns
The normalized path.
- Return type
- class rez.rex.Setenv(*args)[source]
Bases:
rez.rex.EnvAction
- name = 'setenv'
- class rez.rex.Shebang(*args)[source]
Bases:
rez.rex.Action
- name = 'shebang'
- class rez.rex.Source(*args)[source]
Bases:
rez.rex.Action
- name = 'source'
- class rez.rex.Stop(*args)[source]
Bases:
rez.rex.Action
- name = 'stop'
- class rez.rex.Unsetenv(*args)[source]
Bases:
rez.rex.EnvAction
- name = 'unsetenv'
1.1.24. rez.rex_bindings module
Provides wrappers for various types for binding to Rex. We do not want to bind object instances directly in Rex, because this would create an indirect dependency between rex code in package.py files, and versions of Rez.
The classes in this file are intended to have simple interfaces that hide unnecessary data from Rex, and provide APIs that will not change.
- class rez.rex_bindings.EphemeralsBinding(ephemerals)[source]
Bases:
rez.rex_bindings.RO_MappingBinding
Binds a list of resolved ephemeral packages.
Note that the leading ‘.’ is implied when referring to ephemerals. Eg:
# in package.py def commands():
if “foo.cli” in ephemerals: # will match ‘.foo.cli-*’ request
- class rez.rex_bindings.RO_MappingBinding(data)[source]
Bases:
rez.rex_bindings.Binding
A read-only, dict-like object.
- class rez.rex_bindings.RequirementsBinding(requirements)[source]
Bases:
rez.rex_bindings.RO_MappingBinding
Binds a list of version.Requirement objects.
- class rez.rex_bindings.VariantBinding(variant, cached_root=None, interpreter=None)[source]
Bases:
rez.rex_bindings.Binding
Binds a packages.Variant object.
- property root
This is here to support package caching. This ensures that references such as ‘resolve.mypkg.root’ resolve to the cached payload location, if the package is cached.
- class rez.rex_bindings.VariantsBinding(variant_bindings)[source]
Bases:
rez.rex_bindings.RO_MappingBinding
Binds a list of packages.VariantBinding objects, under the package name of each variant.
- class rez.rex_bindings.VersionBinding(version)[source]
Bases:
rez.rex_bindings.Binding
Binds a version.Version object.
>>> v = VersionBinding(Version("1.2.3alpha")) >>> v.major 1 >>> v.patch '3alpha' >>> len(v) 3 >>> v[1] 2 >>> v[:3] (1, 2, '3alpha') >>> str(v) '1.2.3alpha' >>> print(v[5]) None >>> v.as_tuple(): (1, 2, '3alpha')
- property major
- property minor
- property patch
- rez.rex_bindings.intersects(obj, range_)[source]
Test if an object intersects with the given version range.
Examples
# in package.py def commands():
# test a request if intersects(request.maya, ‘2019+’):
info(‘requested maya allows >=2019.*’)
# tests if a resolved version intersects with given range if intersects(resolve.maya, ‘2019+’)
…
# same as above if intersects(resolve.maya.version, ‘2019+’)
…
# disable my cli tools if .foo.cli-0 was specified def commands():
- if intersects(ephemerals.get(‘foo.cli’, ‘1’), ‘1’):
env.PATH.append(‘{root}/bin’)
- Parameters
obj (VariantBinding or str) – Object to test, either a variant, or requirement string (eg ‘foo-1.2.3+’).
range (str) – Version range, eg ‘1.2+<2’
- Returns
True if the object intersects the given range.
- Return type
1.1.25. rez.settings module
1.1.26. rez.shells module
Pluggable API for creating subshells using different programs, such as bash.
- class rez.shells.Shell[source]
Bases:
rez.rex.ActionInterpreter
Class representing a shell, such as bash or tcsh.
- classmethod convert_tokens(value)[source]
Converts any token like ${VAR} and $VAR to shell specific form. Uses the ENV_VAR_REGEX to correctly parse tokens.
- Parameters
value – str to convert
- Returns
str with shell specific variables
- property executable
- classmethod file_extension()[source]
Get the file extension associated with the shell.
- Returns
Shell file extension.
- Return type
- classmethod get_all_key_tokens(key)[source]
Encodes the environment variable into the shell specific forms. Shells might implement multiple forms, but the most common/safest should be always returned at index 0.
- Parameters
key – Variable name to encode
- Returns
list of str with encoded token forms
- classmethod get_key_token(key)[source]
Encodes the environment variable into the shell specific form. Shells might implement multiple forms, but the most common/safest should be returned here.
- Parameters
key – Variable name to encode
- Returns
str of encoded token form
- get_output(style=<OutputStyle.file: ('Code as it would appear in a script file.', )>)[source]
Returns any implementation specific data.
- Parameters
style (OutputStyle) – Style affecting output format.
- Returns
Depends on implementation, but usually a code string.
- classmethod is_available()[source]
Determine if the shell is available to instantiate.
- Returns
True if the shell can be created.
- Return type
- classmethod join(command)[source]
Note: Default to unix sh/bash- friendly behaviour.
- Parameters
command – A sequence of program arguments to be joined into a single string that can be executed in the current shell.
- Returns
A string object representing the command.
- schema_dict = {'prompt': <class 'str'>}
- spawn_shell(context_file, tmpdir, rcfile=None, norc=False, stdin=False, command=None, env=None, quiet=False, pre_command=None, add_rez=True, package_commands_sourced_first=None, **Popen_args)[source]
Spawn a possibly interactive subshell. :param context: _file File that must be sourced in the new shell, this
configures the Rez environment.
- Parameters
tmpdir – Tempfiles, if needed, should be created within this path.
rcfile – Custom startup script.
norc – Don’t run startup scripts. Overrides rcfile.
stdin – If True, read commands from stdin in a non-interactive shell. If a different non-False value, such as subprocess.PIPE, the same occurs, but stdin is also passed to the resulting subprocess.Popen object.
command – If not None, execute this command in a non-interactive shell. If an empty string, don’t run a command, but don’t open an interactive shell either.
env – Environ dict to execute the shell within; uses the current environment if None.
quiet – If True, don’t show the configuration summary, and suppress any stdout from startup scripts.
pre_command – Command to inject before the shell command itself. This is for internal use.
add_rez – If True, assume this shell is being used with rez, and do things such as set the prompt etc.
package_commands_sourced_first – If True, source the context file before sourcing startup scripts (such as .bashrc). If False, source the context file AFTER. If None, use the configured setting.
popen_args – args to pass to the shell process object constructor.
- Returns
A subprocess.Popen object representing the shell process.
- class rez.shells.UnixShell[source]
Bases:
rez.shells.Shell
A base class for common *nix shells, such as bash and tcsh.
- command_arg = '-c'
- classmethod get_all_key_tokens(key)[source]
Encodes the environment variable into the shell specific forms. Shells might implement multiple forms, but the most common/safest should be always returned at index 0.
- Parameters
key – Variable name to encode
- Returns
list of str with encoded token forms
- classmethod get_startup_sequence(rcfile, norc, stdin, command)[source]
Return a dict containing: - ‘stdin’: resulting stdin setting. - ‘command’: resulting command setting. - ‘do_rcfile’: True if a file should be sourced directly. - ‘envvar’: Env-var that points at a file to source at startup. Can be None. - ‘files’: Existing files that will be sourced (non-user-expanded), in source
order. This may also incorporate rcfile, and file pointed at via envvar. Can be empty.
- ‘bind_files’: Files to inject Rez binding into, even if that file doesn’t
already exist.
‘source_bind_files’: Whether to source bind files, if they exist.
- histfile = None
- histvar = None
- last_command_status = '$?'
- norc_arg = None
- rcfile_arg = None
- spawn_shell(context_file, tmpdir, rcfile=None, norc=False, stdin=False, command=None, env=None, quiet=False, pre_command=None, add_rez=True, package_commands_sourced_first=None, **Popen_args)[source]
Spawn a possibly interactive subshell. :param context: _file File that must be sourced in the new shell, this
configures the Rez environment.
- Parameters
tmpdir – Tempfiles, if needed, should be created within this path.
rcfile – Custom startup script.
norc – Don’t run startup scripts. Overrides rcfile.
stdin – If True, read commands from stdin in a non-interactive shell. If a different non-False value, such as subprocess.PIPE, the same occurs, but stdin is also passed to the resulting subprocess.Popen object.
command – If not None, execute this command in a non-interactive shell. If an empty string, don’t run a command, but don’t open an interactive shell either.
env – Environ dict to execute the shell within; uses the current environment if None.
quiet – If True, don’t show the configuration summary, and suppress any stdout from startup scripts.
pre_command – Command to inject before the shell command itself. This is for internal use.
add_rez – If True, assume this shell is being used with rez, and do things such as set the prompt etc.
package_commands_sourced_first – If True, source the context file before sourcing startup scripts (such as .bashrc). If False, source the context file AFTER. If None, use the configured setting.
popen_args – args to pass to the shell process object constructor.
- Returns
A subprocess.Popen object representing the shell process.
- stdin_arg = '-s'
- syspaths = None
- rez.shells.create_shell(shell=None, **kwargs)[source]
Returns a Shell of the given or current type.
- Returns
Instance of given shell.
- Return type
Shell
1.1.27. rez.sigint module
1.1.28. rez.solver module
The dependency resolving module.
This gives direct access to the solver. You should use the resolve() function in resolve.py instead, which will use cached data where possible to provide you with a faster resolve.
See SOLVER.md for an in-depth description of how this module works.
- class rez.solver.Cycle(packages)[source]
Bases:
rez.solver.FailureReason
The solve contains a cyclic dependency.
- class rez.solver.DependencyConflict(dependency, conflicting_request)[source]
Bases:
rez.solver._Common
A common dependency shared by all variants in a scope, conflicted with another scope in the current phase.
- class rez.solver.DependencyConflicts(conflicts)[source]
Bases:
rez.solver.FailureReason
A common dependency in a scope conflicted with another scope in the current phase.
- class rez.solver.PackageVariant(variant, building)[source]
Bases:
rez.solver._Common
A variant of a package.
- property conflict_request_fams
- property handle
- property index
- property name
- property request_fams
- requires_list
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 version
- class rez.solver.Reduction(name, version, variant_index, dependency, conflicting_request)[source]
Bases:
rez.solver._Common
A variant was removed because its dependencies conflicted with another scope in the current phase.
- class rez.solver.Solver(package_requests, package_paths, context=None, package_filter=None, package_orderers=None, callback=None, building=False, optimised=True, verbosity=0, buf=None, package_load_callback=None, prune_unfailed=True, suppress_passive=False, print_stats=False)[source]
Bases:
rez.solver._Common
Solver.
A package solver takes a list of package requests (the ‘request’), then runs a resolve algorithm in order to determine the ‘resolve’ - the list of non-conflicting packages that include all dependencies.
- property cyclic_fail
Return True if the solve failed due to a cycle, False otherwise.
- failure_description(failure_index=None)[source]
Get a description of the failure.
This differs from failure_reason - in some cases, such as when a callback forces a failure, there is more information in the description than there is from failure_reason.
- failure_packages(failure_index=None)[source]
Get packages involved in a failure.
- Parameters
failure_index – See failure_reason.
- Returns
A list of Requirement objects.
- failure_reason(failure_index=None)[source]
Get the reason for a failure.
- Parameters
failure_index –
Index of the fail to return the graph for (can be negative). If None, the most appropriate failure is chosen according to these rules: - If the fail is cyclic, the most recent fail (the one containing
the cycle) is used;
If a callback has caused a failure, the most recent fail is used;
Otherwise, the first fail is used.
- Returns
A FailureReason subclass instance describing the failure.
- get_fail_graph(failure_index=None)[source]
Returns a graph showing a solve failure.
- Parameters
failure_index – See failure_reason
- Returns
A pygraph.digraph object.
- get_graph()[source]
Returns the most recent solve graph.
This gives a graph showing the latest state of the solve. The specific graph returned depends on the solve status. When status is: unsolved: latest unsolved graph is returned; solved: final solved graph is returned; failed: most appropriate failure graph is returned (see failure_reason); cyclic: last failure is returned (contains cycle).
- Returns
A pygraph.digraph object.
- max_verbosity = 3
- property num_fails
Return the number of failed solve steps that have been executed. Note that num_solves is inclusive of failures.
- property num_solves
Return the number of solve steps that have been executed.
- property resolved_ephemerals
Return the list of final ephemeral package ranges.
Note that conflict ephemerals are not included.
- Returns
Final non-conflict ephemerals, or None if the resolve did not complete or was unsuccessful.
- Return type
List of Requirement
- property resolved_packages
Return a list of resolved variants.
- Returns
Resolved variants, or None if the resolve did not complete or was unsuccessful.
- Return type
list of PackageVariant
- property solve_stats
- property status
Return the current status of the solve.
- Returns
Enum representation of the state of the solver.
- Return type
- class rez.solver.SolverCallbackReturn(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Enum returned by the callback callable passed to a Solver instance.
- class rez.solver.SolverState(num_solves, num_fails, phase)[source]
Bases:
object
Represent the current state of the solver instance for use with a callback.
- class rez.solver.SolverStatus(value, names=None, module=None, type=None)[source]
Bases:
rez.vendor.enum.Enum
Enum to represent the current state of a solver instance. The enum also includes a human readable description of what the state represents.
- class rez.solver.TotalReduction(reductions)[source]
Bases:
rez.solver.FailureReason
All of a scope’s variants were reduced away.
1.1.29. rez.source_retrieval module
1.1.30. rez.system module
- class rez.system.System[source]
Bases:
object
Access to underlying system data.
- arch
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
- clear_caches(hard=False)[source]
Clear all caches in Rez.
Rez caches package contents and iteration during a python session. Thus newly released packages, and changes to existing packages, may not be picked up. You need to clear the cache for these changes to become visible.
- Parameters
hard (bool) – Perform a ‘hard’ cache clear. This just means that the memcached cache is also cleared. Generally this is not needed - this option is for debugging purposes.
- domain
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
- fqdn
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
- home
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
- hostname
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 is_production_rez_install
Return True if this is a production rez install.
- os
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
- platform
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
- rez_bin_path
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 rez_version
Returns the current version of Rez.
- property selftest_is_running
Return True if tests are running via rez-selftest tool.
- shell
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
- user
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
- variant
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
1.1.31. rez.util module
Misc useful stuff. TODO: Move this into rez.utils.?
- rez.util.find_last_sublist(list_, sublist)[source]
Given a list, find the last occurance of a sublist within it.
- Returns
Index where the sublist starts, or None if there is no match.
- rez.util.is_non_string_iterable(arg)[source]
Python 2 and 3 compatible non-string iterable identifier