Added 'get_platform()' to construct a string that identifies the current
authorGreg Ward <gward@python.net>
Wed, 1 Mar 2000 14:40:15 +0000 (14:40 +0000)
committerGreg Ward <gward@python.net>
Wed, 1 Mar 2000 14:40:15 +0000 (14:40 +0000)
platform, using 'os.uname()' or 'sys.platform'.

Lib/distutils/util.py

index 58d58439e0b9ffaa1b2c3fae962cb09629cfd13c..641a35af8d618aa67400fbaa441874698797d7d2 100644 (file)
@@ -11,7 +11,7 @@ file causing it."""
 
 __rcsid__ = "$Id$"
 
-import os
+import os, string
 from distutils.errors import *
 
 
@@ -437,3 +437,21 @@ def write_file (filename, contents):
     for line in contents:
         f.write (line + "\n")
     f.close ()
+
+
+def get_platform ():
+    """Return a string (suitable for tacking onto directory names) that
+       identifies the current platform.  Under Unix, identifies both the OS
+       and hardware architecture, e.g. "linux-i586", "solaris-sparc",
+       "irix-mips".  For Windows and Mac OS, just returns 'sys.platform' --
+       i.e. "???" or "???"."""
+
+    if os.name == 'posix':
+        uname = os.uname()
+        OS = uname[0]
+        arch = uname[4]
+        return "%s-%s" % (string.lower (OS), string.lower (arch))
+    else:
+        return sys.platform
+
+# get_platform()