Changed add_target_from_string to include methods to concretize operating_system
This commit is contained in:
parent
2650c60374
commit
d0ae6dd401
@ -90,6 +90,7 @@
|
|||||||
specs to avoid ambiguity. Both are provided because ~ can cause shell
|
specs to avoid ambiguity. Both are provided because ~ can cause shell
|
||||||
expansion when it is the first character in an id typed on the command line.
|
expansion when it is the first character in an id typed on the command line.
|
||||||
"""
|
"""
|
||||||
|
from collections import namedtuple
|
||||||
import sys
|
import sys
|
||||||
import imp
|
import imp
|
||||||
import itertools
|
import itertools
|
||||||
@ -459,7 +460,7 @@ def _set_target(self, target):
|
|||||||
"""Called by the parser to set the target."""
|
"""Called by the parser to set the target."""
|
||||||
if self.target: raise DuplicateTargetError(
|
if self.target: raise DuplicateTargetError(
|
||||||
"Spec for '%s' cannot have two targets." % self.name)
|
"Spec for '%s' cannot have two targets." % self.name)
|
||||||
self.target = target
|
self.target = target # a string can be set
|
||||||
|
|
||||||
|
|
||||||
def _add_dependency(self, spec):
|
def _add_dependency(self, spec):
|
||||||
@ -1231,7 +1232,7 @@ def _autospec(self, spec_like):
|
|||||||
return parse_anonymous_spec(spec_like, self.name)
|
return parse_anonymous_spec(spec_like, self.name)
|
||||||
|
|
||||||
|
|
||||||
def add_target_from_string(self, target):
|
def add_target_from_string(self, arch):
|
||||||
"""If only a target is provided, spack will assume the default architecture.
|
"""If only a target is provided, spack will assume the default architecture.
|
||||||
A platform-target pair can be input delimited by a '-'. If either portion of
|
A platform-target pair can be input delimited by a '-'. If either portion of
|
||||||
a platform-target pair is empty, spack will supply a default, in the case of
|
a platform-target pair is empty, spack will supply a default, in the case of
|
||||||
@ -1240,31 +1241,28 @@ def add_target_from_string(self, target):
|
|||||||
bgq- -> default bgq target (back end/powerpc)
|
bgq- -> default bgq target (back end/powerpc)
|
||||||
cray-hawswell -> haswell target on cray platform
|
cray-hawswell -> haswell target on cray platform
|
||||||
"""
|
"""
|
||||||
if target is None:
|
Arch = namedtuple("Arch", "arch_os target")
|
||||||
|
platform = spack.architecture.sys_type()
|
||||||
|
|
||||||
|
if arch is None:
|
||||||
return
|
return
|
||||||
if '-' in target:
|
|
||||||
platform, target = target.split('-')
|
|
||||||
else:
|
|
||||||
platform = ''
|
|
||||||
|
|
||||||
if platform != '':
|
if '-' in arch:
|
||||||
# Find the class for the platform name given
|
os_name, target = arch.split('-')
|
||||||
file_path = join_path(spack.platform_path, platform)
|
self.target = Arch(arch_os=platform.operating_system(os_name),
|
||||||
platform_mod = imp.load_source('spack.platforms', file_path + '.py')
|
target = platform.target(target))
|
||||||
cls = getattr(platform_mod, mod_to_class(platform))
|
elif arch in platform.targets:
|
||||||
platform = cls()
|
self.target = Arch(arch_os=platform.operating_system('default'),
|
||||||
|
target=platform.target(target))
|
||||||
else:
|
else:
|
||||||
platform = spack.architecture.sys_type()
|
os_name = arch # Odd naming here, definitely need to change
|
||||||
if target != '':
|
self.target = Arch(arch_os=platform.operating_system(os_name),
|
||||||
self.target = platform.target(target)
|
target=platform.target('default'))
|
||||||
else:
|
|
||||||
self.target = platform.target('default')
|
|
||||||
|
|
||||||
|
|
||||||
def satisfies(self, other, deps=True, strict=False):
|
def satisfies(self, other, deps=True, strict=False):
|
||||||
"""Determine if this spec satisfies all constraints of another.
|
"""determine if this spec satisfies all constraints of another.
|
||||||
|
|
||||||
There are two senses for satisfies:
|
there are two senses for satisfies:
|
||||||
|
|
||||||
* `loose` (default): the absence of a constraint in self
|
* `loose` (default): the absence of a constraint in self
|
||||||
implies that it *could* be satisfied by other, so we only
|
implies that it *could* be satisfied by other, so we only
|
||||||
@ -1276,17 +1274,17 @@ def satisfies(self, other, deps=True, strict=False):
|
|||||||
"""
|
"""
|
||||||
other = self._autospec(other)
|
other = self._autospec(other)
|
||||||
|
|
||||||
# A concrete provider can satisfy a virtual dependency.
|
# a concrete provider can satisfy a virtual dependency.
|
||||||
if not self.virtual and other.virtual:
|
if not self.virtual and other.virtual:
|
||||||
pkg = spack.db.get(self.name)
|
pkg = spack.db.get(self.name)
|
||||||
if pkg.provides(other.name):
|
if pkg.provides(other.name):
|
||||||
for provided, when_spec in pkg.provided.items():
|
for provided, when_spec in pkg.provided.items():
|
||||||
if self.satisfies(when_spec, deps=False, strict=strict):
|
if self.satisfies(when_spec, deps=false, strict=strict):
|
||||||
if provided.satisfies(other):
|
if provided.satisfies(other):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Otherwise, first thing we care about is whether the name matches
|
# otherwise, first thing we care about is whether the name matches
|
||||||
if self.name != other.name:
|
if self.name != other.name:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -1296,12 +1294,12 @@ def satisfies(self, other, deps=True, strict=False):
|
|||||||
elif strict and (self.versions or other.versions):
|
elif strict and (self.versions or other.versions):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# None indicates no constraints when not strict.
|
# none indicates no constraints when not strict.
|
||||||
if self.compiler and other.compiler:
|
if self.compiler and other.compiler:
|
||||||
if not self.compiler.satisfies(other.compiler, strict=strict):
|
if not self.compiler.satisfies(other.compiler, strict=strict):
|
||||||
return False
|
return False
|
||||||
elif strict and (other.compiler and not self.compiler):
|
elif strict and (other.compiler and not self.compiler):
|
||||||
return False
|
return True
|
||||||
|
|
||||||
if not self.variants.satisfies(other.variants, strict=strict):
|
if not self.variants.satisfies(other.variants, strict=strict):
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user