summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2016-02-22 14:53:55 -0800
committerMario Melara <maamelara@gmail.com>2016-02-22 14:53:55 -0800
commit1367ccab93e6263e11477abe7ea05f1ad74d88a2 (patch)
tree463f0e2e42a721710ac95d12f3443c4c38c05721 /lib
parent22bf4bc08020898106ef2c8043f102ceeb83ec5c (diff)
downloadspack-1367ccab93e6263e11477abe7ea05f1ad74d88a2.tar.gz
spack-1367ccab93e6263e11477abe7ea05f1ad74d88a2.tar.bz2
spack-1367ccab93e6263e11477abe7ea05f1ad74d88a2.tar.xz
spack-1367ccab93e6263e11477abe7ea05f1ad74d88a2.zip
New folder that will hold operating system subclasses
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/operating_system/__init__.py0
-rw-r--r--lib/spack/spack/operating_system/linux_distro.py25
-rw-r--r--lib/spack/spack/operating_system/mac_osx.py45
3 files changed, 70 insertions, 0 deletions
diff --git a/lib/spack/spack/operating_system/__init__.py b/lib/spack/spack/operating_system/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/lib/spack/spack/operating_system/__init__.py
diff --git a/lib/spack/spack/operating_system/linux_distro.py b/lib/spack/spack/operating_system/linux_distro.py
new file mode 100644
index 0000000000..30a85fe61c
--- /dev/null
+++ b/lib/spack/spack/operating_system/linux_distro.py
@@ -0,0 +1,25 @@
+import platform as py_platform
+import spack
+from spack.architecture import Platform, OperatingSystem
+
+class LinuxDistro(OperatingSystem):
+ """ This class will represent the autodetected operating system
+ for a Linux System. Since there are many different flavors of
+ Linux, this class will attempt to encompass them all through
+ autodetection using the python module platform and the method
+ platform.dist()
+ """
+ def __init__(self):
+ def detect_operating_system():
+ name = py_platform.dist()[0]
+ version = py_platform.dist()[1]
+ return name, version
+
+ name, version = detect_operating_system()
+
+ super(LinuxDistro, self).__init__(name, version)
+
+ @property
+ def compiler_strategy(self):
+ return "PATH"
+
diff --git a/lib/spack/spack/operating_system/mac_osx.py b/lib/spack/spack/operating_system/mac_osx.py
new file mode 100644
index 0000000000..0b939a5546
--- /dev/null
+++ b/lib/spack/spack/operating_system/mac_osx.py
@@ -0,0 +1,45 @@
+""" This class represents the MAC_OSX operating system. This will be auto
+ detected using the python platform.mac_ver. The MAC_OSX platform
+ will be represented using the major version operating system name, i.e
+ el capitan, yosemite...etc.
+"""
+
+import spack
+import os
+import platform as py_platform
+from spack.architecture import Platform, OperatingSystem
+
+class MacOSX(OperatingSystem):
+ def __init__(self):
+ """ Autodetects the mac version from a dictionary. Goes back as
+ far as 10.6 snowleopard. If the user has an older mac then
+ the version will just be a generic mac_os.
+ """
+
+ def get_mac_release():
+ mac_releases = {'10.6': "snowleopard",
+ "10.7": "lion",
+ "10.8": "mountainlion",
+ "10.9": "mavericks",
+ "10.10": "yosemite",
+ "10.11": "elcapitan"}
+
+ mac_ver = py_platform.mac_ver()[0][:-2]
+ try:
+ name = mac_releases[mac_ver]
+ return name, mac_ver
+ except KeyError:
+ name = "mac_os"
+ return name, mac_ver
+
+ name, version = get_mac_release()
+
+ super(MacOSX, self).__init__(name, version)
+
+ @property
+ def compiler_strategy(self):
+ return "PATH"
+
+
+
+