summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/lang.py5
-rw-r--r--lib/spack/spack/architecture.py20
-rw-r--r--lib/spack/spack/directives.py10
-rw-r--r--lib/spack/spack/url.py4
-rw-r--r--lib/spack/spack/virtual.py8
5 files changed, 19 insertions, 28 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index 9e1bef18ca..156ee34c9e 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -87,10 +87,7 @@ def index_by(objects, *funcs):
result = {}
for o in objects:
key = f(o)
- if key not in result:
- result[key] = [o]
- else:
- result[key].append(o)
+ result.setdefault(key, []).append(o)
for key, objects in result.items():
result[key] = index_by(objects, *funcs[1:])
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index 0c4b605e91..05ac5d6f35 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -23,13 +23,12 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
-import platform as py_platform
+import subprocess
from llnl.util.lang import memoized
import spack
import spack.error as serr
-from spack.version import Version
class InvalidSysTypeError(serr.SpackError):
@@ -59,22 +58,23 @@ def get_sys_type_from_environment():
return os.environ.get('SYS_TYPE')
-def get_mac_sys_type():
- """Return a Mac OS SYS_TYPE or None if this isn't a mac."""
- mac_ver = py_platform.mac_ver()[0]
- if not mac_ver:
+def get_sys_type_from_uname():
+ """Return the architecture from uname."""
+ try:
+ arch_proc = subprocess.Popen(['uname', '-i'],
+ stdout=subprocess.PIPE)
+ arch, _ = arch_proc.communicate()
+ return arch.strip()
+ except:
return None
- return "macosx_%s_%s" % (
- Version(mac_ver).up_to(2), py_platform.machine())
-
@memoized
def sys_type():
"""Returns a SysType for the current machine."""
methods = [get_sys_type_from_spack_globals,
get_sys_type_from_environment,
- get_mac_sys_type]
+ get_sys_type_from_uname]
# search for a method that doesn't return None
sys_type = None
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index 9297d6dac3..78039ac6f9 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -239,12 +239,10 @@ def patch(pkg, url_or_filename, level=1, when=None):
when = pkg.name
when_spec = parse_anonymous_spec(when, pkg.name)
- if when_spec not in pkg.patches:
- pkg.patches[when_spec] = [Patch(pkg.name, url_or_filename, level)]
- else:
- # if this spec is identical to some other, then append this
- # patch to the existing list.
- pkg.patches[when_spec].append(Patch(pkg.name, url_or_filename, level))
+ cur_patches = pkg.patches.setdefault(when_spec, [])
+ # if this spec is identical to some other, then append this
+ # patch to the existing list.
+ cur_patches.append(Patch(pkg.name, url_or_filename, level))
@directive('variants')
diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py
index 58838306af..6adbfe156d 100644
--- a/lib/spack/spack/url.py
+++ b/lib/spack/spack/url.py
@@ -209,8 +209,8 @@ def parse_version_offset(path):
# e.g. foobar-4.5.1
(r'-((\d+\.)*\d+)$', stem),
- # e.g. foobar-4.5.1b
- (r'-((\d+\.)*\d+\-?([a-z]|rc|RC|tp|TP)\d*)$', stem),
+ # e.g. foobar-4.5.1b, foobar4.5RC, foobar.v4.5.1b
+ (r'[-._]?v?((\d+\.)*\d+[-._]?([a-z]|rc|RC|tp|TP?)\d*)$', stem),
# e.g. foobar-4.5.0-beta1, or foobar-4.50-beta
(r'-((\d+\.)*\d+-beta(\d+)?)$', stem),
diff --git a/lib/spack/spack/virtual.py b/lib/spack/spack/virtual.py
index fa070e6bd5..c77b259d61 100644
--- a/lib/spack/spack/virtual.py
+++ b/lib/spack/spack/virtual.py
@@ -73,10 +73,8 @@ class ProviderIndex(object):
for provided_spec, provider_spec in pkg.provided.iteritems():
if provider_spec.satisfies(spec, deps=False):
provided_name = provided_spec.name
- if provided_name not in self.providers:
- self.providers[provided_name] = {}
- provider_map = self.providers[provided_name]
+ provider_map = self.providers.setdefault(provided_name, {})
if not provided_spec in provider_map:
provider_map[provided_spec] = set()
@@ -133,9 +131,7 @@ class ProviderIndex(object):
if lp_spec.name == rp_spec.name:
try:
const = lp_spec.copy().constrain(rp_spec,deps=False)
- if constrained not in result:
- result[constrained] = set()
- result[constrained].add(const)
+ result.setdefault(constrained, set()).add(const)
except spack.spec.UnsatisfiableSpecError:
continue
return result