diff options
author | Greg Ward <gward@python.net> | 2000-03-01 14:40:15 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-03-01 14:40:15 (GMT) |
commit | 585df89f60ceb2e0a5b690f12f19c14093faa6fc (patch) | |
tree | 44a59a6f279488f9bd7d16c3c20f416539f2a247 | |
parent | e51d69efb0f1cb319b03224684f184a4bb3fd0bb (diff) | |
download | cpython-585df89f60ceb2e0a5b690f12f19c14093faa6fc.zip cpython-585df89f60ceb2e0a5b690f12f19c14093faa6fc.tar.gz cpython-585df89f60ceb2e0a5b690f12f19c14093faa6fc.tar.bz2 |
Added 'get_platform()' to construct a string that identifies the current
platform, using 'os.uname()' or 'sys.platform'.
-rw-r--r-- | Lib/distutils/util.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index 58d5843..641a35a 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -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() |