Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

architecture: use uname if available #139

Merged
merged 2 commits into from
Oct 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/spack/spack/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down