rez.vendor.version.requirement#

class rez.vendor.version.requirement.VersionedObject#

Definition of a versioned object, eg “foo-1.0”.

“foo” is also a valid object definiton - when there is no version part, we are defining an unversioned object.

Note that ‘-’, ‘@’ or ‘#’ can be used as the seperator between object name and version, however this is purely cosmetic - “foo-1” is the same as “foo@1”.

__init__(s)#
classmethod construct(name, version=None)#

Create a VersionedObject directly from an object name and version.

Parameters:
  • name – Object name string.

  • version – Version object.

property name#

Name of the object.

property version#

Version of the object.

as_exact_requirement()#

Get the versioned object, as an exact requirement string.

Returns:

Equivalent requirement string, eg “maya==2016.1”

class rez.vendor.version.requirement.Requirement#

Requirement for a versioned object.

Examples of valid requirement strings:

foo-1.0 foo@1.0 foo#1.0 foo-1+ foo-1+<4.3 foo<3 foo==1.0.1

Defines a requirement for an object. For example, “foo-5+” means that you require any version of “foo”, version 5 or greater. An unversioned requirement can also be used (“foo”), this means you require any version of foo. You can drop the hyphen between object name and version range if the version range starts with a non-alphanumeric character - eg “foo<2”.

There are two different prefixes that can be applied to a requirement:

  • “!”: The conflict requirement. This means that you require this version range of an object NOT to be present. To conflict with all versions of an object, use “!foo”.

  • “~”: This is known as a “weak reference”, and means, “I do not require this object, but if present, it must be within this range.” It is equivalent to the conflict of the inverse of the given version range.

There is one subtle case to be aware of. “~foo” is a requirement that has no effect - ie, it means “I do not require foo, but if foo is present, it can be any version.” This statement is still valid, but will produce a Requirement object with a None range.

__init__(s, invalid_bound_error=True)#
classmethod construct(name, range=None)#

Create a requirement directly from an object name and VersionRange.

Parameters:
  • name – Object name string.

  • range – VersionRange object. If None, an unversioned requirement is created.

property name#

Name of the required object.

property range#

VersionRange of the requirement.

property conflict#

True if the requirement is a conflict requirement, eg “!foo”, “~foo-1”.

property weak#

True if the requirement is weak, eg “~foo”.

Note that weak requirements are also conflict requirements, but not necessarily the other way around.

safe_str()#

Return a string representation that is safe for the current filesystem, and guarantees that no two different Requirement objects will encode to the same value.

conflicts_with(other)#

Returns True if this requirement conflicts with another Requirement or VersionedObject.

merged(other)#

Returns the merged result of two requirements.

Two requirements can be in conflict and if so, this function returns None. For example, requests for “foo-4” and “foo-6” are in conflict, since both cannot be satisfied with a single version of foo.

Some example successful requirements merges are: - “foo-3+” and “!foo-5+” == “foo-3+<5” - “foo-1” and “foo-1.5” == “foo-1.5” - “!foo-2” and “!foo-5” == “!foo-2|5”

class rez.vendor.version.requirement.RequirementList#

A list of requirements.

This class takes a Requirement list and reduces it to the equivalent optimal form, merging any requirements for common objects. Order of objects is retained.

__init__(requirements)#

Create a RequirementList.

Parameters:

requirements – List of Requirement objects.

property requirements#

Returns optimised list of requirements, or None if there are conflicts.

property conflict#

Get the requirement conflict, if any.

Returns:

None if there is no conflict, otherwise a 2-tuple containing the conflicting Requirement objects.

property names#

Set of names of requirements, not including conflict requirements.

property conflict_names#

Set of conflict requirement names.

get(name)#

Returns the Requirement for the given object, or None.