Skip to content

Instantly share code, notes, and snippets.

@davidlatwe
Last active November 6, 2020 23:57
Show Gist options
  • Save davidlatwe/c2bfed913d1d95e2872dd468cf213405 to your computer and use it in GitHub Desktop.
Save davidlatwe/c2bfed913d1d95e2872dd468cf213405 to your computer and use it in GitHub Desktop.
Testing Rez's conflict resolve and package not found detailed message
import os
os.environ["REZ_PACKAGES_PATH"] = "memory@any"
def memory_repository(packages):
from rez.package_repository import package_repository_manager
repository = package_repository_manager.get_repository("memory@any")
repository.data = packages
if __name__ == "__main__":
from rez.resolved_context import ResolvedContext
from rez.exceptions import PackageFamilyNotFoundError
memory_repository({
# Conflict on merge
"bar": {
"1": {
"name": "bar",
"version": "1",
"requires": [
"dep==2",
],
}
},
"foo": {
"1": {
"name": "foo",
"version": "1",
"requires": [
"dep==1",
],
}
},
"dep": {
"1": {
"name": "dep",
"version": "1",
},
"2": {
"name": "dep",
"version": "2",
},
},
# Conflict on intersect
"tom": {
"1": {
"name": "tom",
"version": "1",
"requires": [
"kai==1",
],
}
},
"dav": {
"1": {
"name": "dav",
"version": "1",
"requires": [
"kai==1",
],
}
},
"kai": {
"1": {
"name": "kai",
"version": "1",
},
"2": {
"name": "kai",
"version": "2",
},
},
# Deeper conflict
"pipeline": {
"1": {
"name": "pipeline",
"version": "1",
"requires": [
"maya-2020",
],
}
},
"maya": {
"2020": {
"name": "maya",
"version": "2020",
"requires": [
"pymel",
],
}
},
"pymel": {
"2": {
"name": "pymel",
"version": "2",
"requires": [
"python==2",
],
}
},
"houdini": {
"18": {
"name": "houdini",
"version": "18",
"requires": [
"python==3",
],
}
},
"python": {
"2": {
"name": "python",
"version": "2",
},
"3": {
"name": "python",
"version": "3",
},
},
# Package not found
"dummy": {
"1": {
"name": "dummy",
"version": "1",
"requires": [
"oops==1",
],
},
"2": {
"name": "dummy",
"version": "2",
"requires": [
"oops==2",
],
}
},
# Package not found
"miely": {
"1": {
"name": "miely",
"version": "1",
"requires": [
"dummy>1",
],
}
},
# Cycles
"nuke": {
"11": {
"name": "nuke",
"version": "11",
"requires": [
"cycle==00",
"python==3",
],
}
},
"cycle": {
"00": {
"name": "cycle",
"version": "00",
"requires": [
"nuke",
],
},
"99": {
"name": "cycle",
"version": "99",
"requires": [
"nuke",
],
}
},
})
print("\nConflict on merge")
print("=" * 20)
context = ResolvedContext(["foo", "bar"])
context.print_info()
print("\nConflict on intersect")
print("=" * 20)
context = ResolvedContext(["tom", "dav", "kai==2"])
context.print_info()
print("\nConflict on intersect (deeper)")
print("=" * 20)
context = ResolvedContext(["pipeline", "maya", "houdini"])
context.print_info()
print("\nRequired package not found")
print("=" * 20)
try:
context = ResolvedContext(["dummy"])
except PackageFamilyNotFoundError as e:
print(e)
print("\nRequired package not found (deeper)")
print("=" * 20)
try:
context = ResolvedContext(["miely"])
except PackageFamilyNotFoundError as e:
print(e)
print("\nCycle")
print("=" * 20)
context = ResolvedContext(["nuke"])
context.print_info()
print("\nConflict on intersect (with cycle hidden)")
print("=" * 20)
context = ResolvedContext(["pipeline", "nuke", "maya"])
context.print_info()
Conflict on merge
====================
The context failed to resolve:
The following package conflicts occurred: (dep==1 <--!--> dep==2)
dep==1: foo==1
dep==2: bar==1
Conflict on intersect
====================
The context failed to resolve:
The following package conflicts occurred: (kai==1 <--!--> kai==2)
kai==1: tom==1
kai==2: -
Conflict on intersect (deeper)
====================
The context failed to resolve:
The following package conflicts occurred: (python==2 <--!--> python==3)
python==2: pymel==2 <-- maya==2020 <-- pipeline==1
python==3: houdini==18
Required package not found
====================
package family not found: oops, was required by: dummy==1|==2 (searched: memory@any)
Required package not found (deeper)
====================
package family not found: oops, was required by: dummy==2 (searched: memory@any)
Cycle
====================
The context failed to resolve:
A cyclic dependency was detected: nuke-11 --> cycle-00 --> nuke-11
Conflict on intersect (with cycle hidden)
====================
The context failed to resolve:
The following package conflicts occurred: (python==2 <--!--> python==3)
python==2: pymel==2 <-- maya==2020 <-- pipeline==1
python==3: nuke==11 <-- cycle==00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment