-
Notifications
You must be signed in to change notification settings - Fork 4
/
recipe.py
52 lines (42 loc) · 1.63 KB
/
recipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from rez.vendor.version.version import VersionRange
from rez.utils.formatting import PackageRequest
from package_list import PackageList
class Recipe:
def __init__(
self,
name: str,
range: VersionRange,
variant: PackageList,
requires: PackageList,
build_requires: PackageList,
installed: bool,
):
if range is None:
self.pkg = PackageRequest(f"{name}")
else:
self.pkg = PackageRequest(f"{name}-{range}")
self.variant = variant
self.requires = requires
self.build_requires = build_requires
self.installed = installed
def conflicts_with_package(self, rhs: PackageRequest) -> bool:
if self.pkg.name == rhs.name and not self.pkg.range.intersects(rhs.range):
return f"{self.pkg} <-!-> {rhs}"
for v in [self.variant, self.requires, self.build_requires]:
vc = v.has_conflicts_with(rhs)
if vc:
return vc
return False
def conflicts_with_package_list(self, rhs: PackageList) -> bool:
for p in rhs:
if self.pkg.name == p.name and not self.pkg.range.intersects(p.range):
# print(f" recipe {self.pkg} conflicts with {p}")
return f"{self.pkg} <-!-> {p}"
for v in [self.variant, self.requires, self.build_requires]:
vc = v.has_conflicts_with(rhs)
if vc:
return vc
return False
def __str__(self):
namever = f"{self.pkg.name}-{self.pkg.range}"
return f"{namever}/{'/'.join([str(p) for p in self.variant])}"