Skip to content

Commit

Permalink
WIP: add TODO items for deptypes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathstuf committed Jan 25, 2016
1 parent d06414c commit d134113
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/spack/spack/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def topological_sort(spec, **kwargs):
"""
reverse = kwargs.get('reverse', False)
# XXX(deptype): iterate over a certain kind of dependency. Maybe color
# edges based on the type of dependency?
if not reverse:
parents = lambda s: s.dependents()
children = lambda s: s.dependencies()
Expand Down
1 change: 1 addition & 0 deletions lib/spack/spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ def preorder_traversal(self, visited=None, **kwargs):

for name in sorted(self._dependencies.keys()):
spec, deptypes = self.get_dependency(name)
# XXX(deptype): use deptypes

# Currently, we do not descend into virtual dependencies, as this
# makes doing a sensible traversal much harder. We just assume that
Expand Down
15 changes: 15 additions & 0 deletions lib/spack/spack/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ def _set_architecture(self, architecture):


def _add_dependency(self, spec, deptypes):
# XXX(deptype): fix up callers
"""Called by the parser to add another spec as a dependency."""
if spec.name in self._dependencies:
raise DuplicateDependencyError("Cannot depend on '%s' twice" % spec)
Expand Down Expand Up @@ -686,6 +687,7 @@ def to_node_dict(self):
'variants' : dict(
(name,v.enabled) for name, v in self.variants.items()),
'arch' : self.architecture,
# XXX(deptype): iterate over dependency kinds.
'dependencies' : dict((d, self._dependencies[d].spec.dag_hash())
for d in sorted(self._dependencies))
}
Expand Down Expand Up @@ -731,6 +733,7 @@ def from_node_dict(node):
for name, enabled in node['variants'].items():
spec.variants[name] = VariantSpec(name, enabled)

# XXX(deptype): return the deptype as well?
return spec


Expand Down Expand Up @@ -763,6 +766,7 @@ def from_yaml(stream):
for node in yfile['spec']:
name = next(iter(node))
for dep_name in node[name]['dependencies']:
# XXX(deptype): grab the deptypes as well
deps[name]._dependencies[dep_name] = deps[dep_name]
return spec

Expand Down Expand Up @@ -920,6 +924,7 @@ def flat_dependencies(self, **kwargs):
"""
copy = kwargs.get('copy', True)

# XXX(deptype): use a deptype kwarg.
flat_deps = DependencyMap()
try:
for spec in self.traverse(root=False):
Expand Down Expand Up @@ -951,6 +956,7 @@ def index(self):
"""Return DependencyMap that points to all the dependencies in this
spec."""
dm = DependencyMap()
# XXX(deptype): use a deptype kwarg.
for spec in self.traverse():
dm[spec.name] = spec
return dm
Expand Down Expand Up @@ -1058,6 +1064,7 @@ def _merge_dependency(self, dep, visited, spec_deps, provider_index):
raise UnsatisfiableProviderSpecError(required[0], dep)
provider_index.update(dep)

# XXX(deptype): handle deptypes? we were handed this list.
# If the spec isn't already in the set of dependencies, clone
# it from the package description.
if dep.name not in spec_deps:
Expand Down Expand Up @@ -1103,6 +1110,7 @@ def _normalize_helper(self, visited, spec_deps, provider_index):
pkg = spack.repo.get(self.fullname)
while changed:
changed = False
# XXX(deptype): handle deptypes. deptype kwarg?
for dep_name in pkg.dependencies:
# Do we depend on dep_name? If so pkg_dep is not None.
pkg_dep = self._evaluate_dependency_conditions(dep_name)
Expand Down Expand Up @@ -1139,6 +1147,8 @@ def normalize(self, force=False):
# Ensure first that all packages & compilers in the DAG exist.
self.validate_names()

# XXX(deptype): handle deptypes. need to look more into what this
# method is for/does.
# Get all the dependencies into one DependencyMap
spec_deps = self.flat_dependencies(copy=False)

Expand Down Expand Up @@ -1268,6 +1278,7 @@ def _constrain_dependencies(self, other):

def common_dependencies(self, other):
"""Return names of dependencies that self an other have in common."""
# XXX(deptype): handle deptypes via deptype kwarg.
common = set(
s.name for s in self.traverse(root=False))
common.intersection_update(
Expand All @@ -1284,6 +1295,7 @@ def constrained(self, other, deps=True):

def dep_difference(self, other):
"""Returns dependencies in self that are not in other."""
# XXX(deptype): handle deptypes via deptype kwarg.
mine = set(s.name for s in self.traverse(root=False))
mine.difference_update(
s.name for s in other.traverse(root=False))
Expand Down Expand Up @@ -1362,6 +1374,7 @@ def satisfies(self, other, deps=True, strict=False):
elif strict and (other.architecture and not self.architecture):
return False

# XXX(deptype): handle deptypes via deptype kwarg?
# If we need to descend into dependencies, do it, otherwise we're done.
if deps:
return self.satisfies_dependencies(other, strict=strict)
Expand All @@ -1373,6 +1386,7 @@ def satisfies_dependencies(self, other, strict=False):
"""This checks constraints on common dependencies against each other."""
other = self._autospec(other)

# XXX(deptype): handle deptypes?
if strict:
if other._dependencies and not self._dependencies:
return False
Expand Down Expand Up @@ -1507,6 +1521,7 @@ def __contains__(self, spec):

def sorted_deps(self):
"""Return a list of all dependencies sorted by name."""
# XXX(deptype): take a deptype arg?
deps = self.flat_dependencies()
return tuple(deps[name] for name in sorted(deps))

Expand Down

0 comments on commit d134113

Please sign in to comment.