summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-11-04 16:49:19 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-11-04 16:49:19 -0700
commit78154a63e86774fb8952f42883f7788e94d0c8d2 (patch)
treec34c6e8c184252d0904febffd46a42135133a8a3
parent9cd83a4efb6633b83e0ad2ef640d0b275f39b28c (diff)
downloadspack-78154a63e86774fb8952f42883f7788e94d0c8d2.tar.gz
spack-78154a63e86774fb8952f42883f7788e94d0c8d2.tar.bz2
spack-78154a63e86774fb8952f42883f7788e94d0c8d2.tar.xz
spack-78154a63e86774fb8952f42883f7788e94d0c8d2.zip
Fix bug in distribution detection on unsupported platforms.
-rw-r--r--lib/spack/spack/operating_systems/linux_distro.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/spack/spack/operating_systems/linux_distro.py b/lib/spack/spack/operating_systems/linux_distro.py
index e18dab38fc..b9a39361da 100644
--- a/lib/spack/spack/operating_systems/linux_distro.py
+++ b/lib/spack/spack/operating_systems/linux_distro.py
@@ -1,5 +1,4 @@
import re
-from external.distro import linux_distribution
from spack.architecture import OperatingSystem
@@ -12,9 +11,14 @@ class LinuxDistro(OperatingSystem):
"""
def __init__(self):
- distname, version, _ = linux_distribution(
- full_distribution_name=False)
- distname, version = str(distname), str(version)
+ try:
+ # This will throw an error if imported on a non-Linux platform.
+ from external.distro import linux_distribution
+ distname, version, _ = linux_distribution(
+ full_distribution_name=False)
+ distname, version = str(distname), str(version)
+ except ImportError as e:
+ distname, version = 'unknown', ''
# Grabs major version from tuple on redhat; on other platforms
# grab the first legal identifier in the version field. On