summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/util.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-09-15 01:16:14 (GMT)
committerGreg Ward <gward@python.net>2000-09-15 01:16:14 (GMT)
commit59399bb303a51e781ab7943088fa1c4db1d41dcb (patch)
tree6b14ad67481fe86088a3b93cd620c25ec32eff74 /Lib/distutils/util.py
parent879f0f11ba8b8d8098916235e1b5931a3eb6c8b5 (diff)
downloadcpython-59399bb303a51e781ab7943088fa1c4db1d41dcb.zip
cpython-59399bb303a51e781ab7943088fa1c4db1d41dcb.tar.gz
cpython-59399bb303a51e781ab7943088fa1c4db1d41dcb.tar.bz2
Revamped 'get_platform()' to try and do something reasonably smart on
POSIX platforms, ie. get a little more detail than 'sys.platform' gives.
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r--Lib/distutils/util.py46
1 files changed, 42 insertions, 4 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 2487f6d..4688871 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -13,11 +13,49 @@ from distutils.spawn import spawn
def get_platform ():
- """Return a string (suitable for tacking onto directory names) that
- identifies the current platform. Currently, this is just
- 'sys.platform'.
+ """Return a string that identifies the current platform. This is used
+ mainly to distinguish platform-specific build directories and
+ platform-specific built distributions. Typically includes the OS name
+ and version and the architecture (as supplied by 'os.uname()'),
+ although the exact information included depends on the OS; eg. for IRIX
+ the architecture isn't particularly important (IRIX only runs on SGI
+ hardware), but for Linux the kernel version isn't particularly
+ important.
+
+ Examples of returned values:
+ linux-i586
+ linux-alpha (?)
+ solaris-2.6-sun4u
+ irix-5.3
+ irix64-6.2
+
+ For non-POSIX platforms, currently just returns 'sys.platform'.
"""
- return sys.platform
+ if os.name != "posix":
+ # XXX what about the architecture? NT is Intel or Alpha,
+ # Mac OS is M68k or PPC, etc.
+ return sys.platform
+
+ # Try to distinguish various flavours of Unix
+
+ (osname, host, release, version, machine) = os.uname()
+ osname = string.lower(osname)
+ if osname[:5] == "linux":
+ # At least on Linux/Intel, 'machine' is the processor --
+ # i386, etc.
+ # XXX what about Alpha, SPARC, etc?
+ return "%s-%s" % (osname, machine)
+ elif osname[:5] == "sunos":
+ if release[0] >= "5": # SunOS 5 == Solaris 2
+ osname = "solaris"
+ release = "%d.%s" % (int(release[0]) - 3, release[2:])
+ # fall through to standard osname-release-machine representation
+ elif osname[:4] == "irix": # could be "irix64"!
+ return "%s-%s" % (osname, release)
+
+ return "%s-%s-%s" % (osname, release, machine)
+
+# get_platform ()
def convert_path (pathname):