rez.rex_bindings
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_MappingBindingBinds 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.BindingA read-only, dict-like object.
- class rez.rex_bindings.RequirementsBinding(requirements)[source]
Bases:
rez.rex_bindings.RO_MappingBindingBinds a list of version.Requirement objects.
- class rez.rex_bindings.VariantBinding(variant, cached_root=None, interpreter=None)[source]
Bases:
rez.rex_bindings.BindingBinds 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_MappingBindingBinds a list of packages.VariantBinding objects, under the package name of each variant.
- class rez.rex_bindings.VersionBinding(version)[source]
Bases:
rez.rex_bindings.BindingBinds 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