whitespace and formatting

This commit is contained in:
Todd Gamblin 2016-03-02 22:38:21 -08:00
parent 048c406f49
commit 1fe196f95c
3 changed files with 26 additions and 25 deletions

View File

@ -33,8 +33,8 @@ def __init__(self):
self.preferred = spack.config.get_config('packages') self.preferred = spack.config.get_config('packages')
self._spec_for_pkgname_cache = {} self._spec_for_pkgname_cache = {}
#Given a package name, sort component (e.g, version, compiler, ...), and # Given a package name, sort component (e.g, version, compiler, ...), and
# a second_key (used by providers), return the list # a second_key (used by providers), return the list
def _order_for_package(self, pkgname, component, second_key, test_all=True): def _order_for_package(self, pkgname, component, second_key, test_all=True):
pkglist = [pkgname] pkglist = [pkgname]
if test_all: if test_all:
@ -47,10 +47,10 @@ def _order_for_package(self, pkgname, component, second_key, test_all=True):
continue continue
return [str(s).strip() for s in order] return [str(s).strip() for s in order]
return [] return []
# A generic sorting function. Given a package name and sort
# component, return less-than-0, 0, or greater-than-0 if # A generic sorting function. Given a package name and sort
# component, return less-than-0, 0, or greater-than-0 if
# a is respectively less-than, equal to, or greater than b. # a is respectively less-than, equal to, or greater than b.
def _component_compare(self, pkgname, component, a, b, reverse_natural_compare, second_key): def _component_compare(self, pkgname, component, a, b, reverse_natural_compare, second_key):
if a is None: if a is None:
@ -76,7 +76,7 @@ def _component_compare(self, pkgname, component, a, b, reverse_natural_compare,
cmp_a = orderlist.index(str(a)) cmp_a = orderlist.index(str(a))
cmp_b = orderlist.index(str(b)) cmp_b = orderlist.index(str(b))
reverse = 1 reverse = 1
if cmp_a < cmp_b: if cmp_a < cmp_b:
return -1 * reverse return -1 * reverse
elif cmp_a > cmp_b: elif cmp_a > cmp_b:
@ -87,7 +87,7 @@ def _component_compare(self, pkgname, component, a, b, reverse_natural_compare,
# A sorting function for specs. Similar to component_compare, but # A sorting function for specs. Similar to component_compare, but
# a and b are considered to match entries in the sorting list if they # a and b are considered to match entries in the sorting list if they
# satisfy the list component. # satisfy the list component.
def _spec_compare(self, pkgname, component, a, b, reverse_natural_compare, second_key): def _spec_compare(self, pkgname, component, a, b, reverse_natural_compare, second_key):
if not a or not a.concrete: if not a or not a.concrete:
return -1 return -1
@ -121,7 +121,7 @@ def _spec_for_pkgname(self, pkgname, component, second_key):
key = (pkgname, component, second_key) key = (pkgname, component, second_key)
if not key in self._spec_for_pkgname_cache: if not key in self._spec_for_pkgname_cache:
pkglist = self._order_for_package(pkgname, component, second_key) pkglist = self._order_for_package(pkgname, component, second_key)
if not pkglist: if not pkglist:
if component in self._default_order: if component in self._default_order:
pkglist = self._default_order[component] pkglist = self._default_order[component]
if component == 'compiler': if component == 'compiler':
@ -132,9 +132,9 @@ def _spec_for_pkgname(self, pkgname, component, second_key):
self._spec_for_pkgname_cache[key] = [spack.spec.Spec(s) for s in pkglist] self._spec_for_pkgname_cache[key] = [spack.spec.Spec(s) for s in pkglist]
return self._spec_for_pkgname_cache[key] return self._spec_for_pkgname_cache[key]
def provider_compare(self, pkgname, provider_str, a, b): def provider_compare(self, pkgname, provider_str, a, b):
"""Return less-than-0, 0, or greater than 0 if a is respecively less-than, equal-to, or """Return less-than-0, 0, or greater than 0 if a is respecively less-than, equal-to, or
greater-than b. A and b are possible implementations of provider_str. greater-than b. A and b are possible implementations of provider_str.
One provider is less-than another if it is preferred over the other. One provider is less-than another if it is preferred over the other.
For example, provider_compare('scorep', 'mpi', 'mvapich', 'openmpi') would return -1 if For example, provider_compare('scorep', 'mpi', 'mvapich', 'openmpi') would return -1 if
@ -148,28 +148,28 @@ def spec_has_preferred_provider(self, pkgname, provider_str):
def version_compare(self, pkgname, a, b): def version_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if version a of pkgname is """Return less-than-0, 0, or greater than 0 if version a of pkgname is
respecively less-than, equal-to, or greater-than version b of pkgname. respecively less-than, equal-to, or greater-than version b of pkgname.
One version is less-than another if it is preferred over the other.""" One version is less-than another if it is preferred over the other."""
return self._spec_compare(pkgname, 'version', a, b, True, None) return self._spec_compare(pkgname, 'version', a, b, True, None)
def variant_compare(self, pkgname, a, b): def variant_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if variant a of pkgname is """Return less-than-0, 0, or greater than 0 if variant a of pkgname is
respecively less-than, equal-to, or greater-than variant b of pkgname. respecively less-than, equal-to, or greater-than variant b of pkgname.
One variant is less-than another if it is preferred over the other.""" One variant is less-than another if it is preferred over the other."""
return self._component_compare(pkgname, 'variant', a, b, False, None) return self._component_compare(pkgname, 'variant', a, b, False, None)
def architecture_compare(self, pkgname, a, b): def architecture_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if architecture a of pkgname is """Return less-than-0, 0, or greater than 0 if architecture a of pkgname is
respecively less-than, equal-to, or greater-than architecture b of pkgname. respecively less-than, equal-to, or greater-than architecture b of pkgname.
One architecture is less-than another if it is preferred over the other.""" One architecture is less-than another if it is preferred over the other."""
return self._component_compare(pkgname, 'architecture', a, b, False, None) return self._component_compare(pkgname, 'architecture', a, b, False, None)
def compiler_compare(self, pkgname, a, b): def compiler_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if compiler a of pkgname is """Return less-than-0, 0, or greater than 0 if compiler a of pkgname is
respecively less-than, equal-to, or greater-than compiler b of pkgname. respecively less-than, equal-to, or greater-than compiler b of pkgname.
One compiler is less-than another if it is preferred over the other.""" One compiler is less-than another if it is preferred over the other."""
return self._spec_compare(pkgname, 'compiler', a, b, False, None) return self._spec_compare(pkgname, 'compiler', a, b, False, None)

View File

@ -428,7 +428,7 @@ def __init__(self, spec_like, *dep_like, **kwargs):
for dep in dep_like: for dep in dep_like:
spec = dep if isinstance(dep, Spec) else Spec(dep) spec = dep if isinstance(dep, Spec) else Spec(dep)
self._add_dependency(spec) self._add_dependency(spec)
# #
# Private routines here are called by the parser when building a spec. # Private routines here are called by the parser when building a spec.
@ -1410,7 +1410,7 @@ def _dup(self, other, **kwargs):
self.architecture != other.architecture and self.compiler != other.compiler and \ self.architecture != other.architecture and self.compiler != other.compiler and \
self.variants != other.variants and self._normal != other._normal and \ self.variants != other.variants and self._normal != other._normal and \
self.concrete != other.concrete and self.external != other.external) self.concrete != other.concrete and self.external != other.external)
# Local node attributes get copied first. # Local node attributes get copied first.
self.name = other.name self.name = other.name
self.versions = other.versions.copy() self.versions = other.versions.copy()
@ -1585,7 +1585,7 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
$@ Version with '@' prefix $@ Version with '@' prefix
$% Compiler with '%' prefix $% Compiler with '%' prefix
$%@ Compiler with '%' prefix & compiler version with '@' prefix $%@ Compiler with '%' prefix & compiler version with '@' prefix
$+ Options $+ Options
$= Architecture with '=' prefix $= Architecture with '=' prefix
$# 7-char prefix of DAG hash with '-' prefix $# 7-char prefix of DAG hash with '-' prefix
$$ $ $$ $
@ -1738,7 +1738,7 @@ def __cmp__(self, other):
#Package name sort order is not configurable, always goes alphabetical #Package name sort order is not configurable, always goes alphabetical
if self.name != other.name: if self.name != other.name:
return cmp(self.name, other.name) return cmp(self.name, other.name)
#Package version is second in compare order #Package version is second in compare order
pkgname = self.name pkgname = self.name
if self.versions != other.versions: if self.versions != other.versions:

View File

@ -34,8 +34,9 @@ def install(self, spec, prefix):
env['PYTHONHOME'] = prefix env['PYTHONHOME'] = prefix
env['MACOSX_DEPLOYMENT_TARGET'] = '10.6' env['MACOSX_DEPLOYMENT_TARGET'] = '10.6'
# Rest of install is pretty standard except setup.py needs to be able to read the CPPFLAGS # Rest of install is pretty standard except setup.py needs to
# and LDFLAGS as it scans for the library and headers to build # be able to read the CPPFLAGS and LDFLAGS as it scans for the
# library and headers to build
configure_args= [ configure_args= [
"--prefix=%s" % prefix, "--prefix=%s" % prefix,
"--with-threads", "--with-threads",