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.Binding#

Abstract base class.

__init__(data=None)#
class rez.rex_bindings.VersionBinding#

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')
__init__(version)#
class rez.rex_bindings.VariantBinding#

Binds a packages.Variant object.

__init__(variant, cached_root=None, interpreter=None)#
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.RO_MappingBinding#

A read-only, dict-like object.

__init__(data)#
class rez.rex_bindings.VariantsBinding#

Binds a list of packages.VariantBinding objects, under the package name of each variant.

__init__(variant_bindings)#
class rez.rex_bindings.RequirementsBinding#

Binds a list of version.Requirement objects.

__init__(requirements)#
get_range(name, default=None)#

Returns requirement version range object

class rez.rex_bindings.EphemeralsBinding#

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

__init__(ephemerals)#
get_range(name, default=None)#

Returns ephemeral version range object

rez.rex_bindings.intersects(obj, range_)#

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:

bool