classification
Title: platform.dist(): detect Linux distribution version in a robust, standard way
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Deprecate platform.dist() and platform.linux_distribution() functions
View: 1322
Assigned To: lemburg Nosy List: draghuram, lemburg, zooko
Priority: normal Keywords: patch

Created on 2008-09-22 22:13 by zooko, last changed 2010-08-12 02:32 by zooko. This issue is now closed.

Files
File name Uploaded Description Edit
dist.patch.txt zooko, 2008-09-22 22:13 patch to platform.dist() to execute lsb_release
dist.patch.txt zooko, 2008-09-22 22:45
dist.patch.txt zooko, 2008-09-23 17:15
Messages (6)
msg73601 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2008-09-22 22:13
platform.dist() returns ('debian', 'lenny/sid', '') on my Ubuntu 8.04
Hardy system.  Investigating shows that there are a few techniques in
platform.py to parse the version-number-files of different Linux
distributions.  This patch adds a command to try executing "lsb_release"
first of all.  lsb_release is the standard way to do this, originally
published in 2001:

http://refspecs.freestandards.org/LSB_1.0.0/gLSB/lsbrelease.html

and currently standardized here:

http://refspecs.freestandards.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html

If invoking "lsb_release" results in exit code 0 and some non-empty,
non-all-whitespace string on stdout, then dist() returns that.  Else,
dist falls back to the old (current) hacks.

There is a drawback to this: invoking three successive subprocesses
takes a bit of time.  Hopefully nobody needs to invoke platform.dist()
in a time-critical moment...

With this patch, platform.dist() return:
('Ubuntu', '8.04', 'hardy')

Oh, this patch also updates the docstring of dist() to explain what is
meant by "distribution", "version", and "id".
msg73604 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2008-09-22 22:45
Here's a new version of this patch which differs only in having slightly
more correct documentation.
msg73641 - (view) Author: Raghuram Devarakonda (draghuram) (Python triager) Date: 2008-09-23 14:12
Please take a look at #1322 for some discussion on this topic.
msg73651 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2008-09-23 17:15
Here is an updated version of my patch which tries parsing
/etc/lsb-release first and only if that fails tries executing
lsb_release.  The reason is that executing lsb_release in a subprocess
takes half-a-second on my high-performance Athlon64 Ubuntu workstation,
and also that some installations have /etc/lsb-release but not
lsb_release.  See the docstring for more details about why to do it this
way and exactly what it does.
msg73653 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2008-09-23 18:10
As explained in #1322. platform.dist() has been superseded by
platform.linux_distribution().

Please check what platform.linux_distribution() returns on your platform
using Python 2.6rc2.

I'm closing this ticket since it's basically a duplicate of #1322.
msg113650 - (view) Author: Zooko O'Whielacronx (zooko) Date: 2010-08-12 02:32
> Please check what platform.linux_distribution() returns on your platform using Python 2.6rc2.

Here are the results of that. Summary: looks fine to me.

http://tahoe-lafs.org/buildbot/waterfall

Here are the scripts that are generating these results:

http://tahoe-lafs.org/trac/tahoe-lafs/browser/trunk/misc/build_helpers/show-tool-versions.py?rev=4643#L8

http://tahoe-lafs.org/trac/tahoe-lafs/browser/trunk/src/allmydata/__init__.py?rev=4687#L80

The relevant parts of the results are summarized below:

http://tahoe-lafs.org/buildbot/builders/Eugen lenny-amd64

platform: Linux-2.6.26-1-vserver-amd64-x86_64-with-debian-5.0.5

python: 2.5.2 (r252:60911, Jan 24 2010, 17:44:40)  [GCC 4.3.2]
maxunicode: 1114111

platform: Linux-debian_5.0.5-x86_64-64bit



http://tahoe-lafs.org/buildbot/builders/hardy-amd64

platform: Linux-2.6.32-24-server-x86_64-with-Ubuntu-10.04-lucid
linux_distribution: ('Ubuntu', '10.04', 'lucid')

python: 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)  [GCC 4.4.3]
maxunicode: 1114111

platform: Linux-Ubuntu_10.04-x86_64-64bit_ELF



http://tahoe-lafs.org/buildbot/builders/Shawn jaunty amd64

platform: Linux-2.6.32-24-generic-x86_64-with-Ubuntu-10.04-lucid
linux_distribution: ('Ubuntu', '10.04', 'lucid')

python: 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)  [GCC 4.4.3]
maxunicode: 1114111

platform: Linux-Ubuntu_10.04-x86_64-64bit_ELF



http://tahoe-lafs.org/buildbot/builders/Zooko ubuntu-amd64 yukyuk

platform: Linux-2.6.32.8yukyuk36-x86_64-with-Ubuntu-10.04-lucid

python: 2.6.4+ (r264:75706, Feb 16 2010, 02:54:39)  [GCC 4.4.3], maxunicode: 1114111

platform: Linux-Ubuntu_10.04-x86_64-64bit_ELF



http://tahoe-lafs.org/buildbot/builders/Ruben Fedora

platform: Linux-2.6.33.5-rscloud-x86_64-with-fedora-15-Rawhide
linux_distribution: ('Fedora', '15', 'Rawhide')

python: 2.7 (r27:82500, Jul 26 2010, 18:19:48)  [GCC 4.5.0 20100716 (Red Hat 4.5.0-3)]
maxunicode: 1114111

platform: Linux-fedora_15-x86_64-64bit_ELF



http://tahoe-lafs.org/buildbot/builders/Arthur lenny c7 32bit

platform: Linux-2.6.24dedibox-r8-c7-i686-with-debian-5.0.5

python: 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)  [GCC 4.3.2]
maxunicode: 1114111

platform: Linux-debian_5.0.5-i686-32bit



http://tahoe-lafs.org/buildbot/builders/David A. OpenSolaris i386

platform: SunOS-5.11-i86pc-i386-32bit

python: 2.5.2 (r252:60911, Mar 11 2009, 04:50:47) [C]
maxunicode: 65535

platform: SunOS-5.11-i86pc-i386-32bit



http://tahoe-lafs.org/buildbot/builders/Randy FreeBSD-amd64

platform: FreeBSD-8.1-STABLE-amd64-64bit-ELF

python: 2.5.5 (r255:77872, Mar 12 2010, 08:40:28)  [GCC 4.2.1 20070719  [FreeBSD]]
maxunicode: 1114111




http://tahoe-lafs.org/buildbot/builders/Kyle OpenBSD-4.6 amd64

platform: OpenBSD-4.6-amd64-Genuine_Intel-R-_CPU_000_@_2.93GHz-64bit-ELF
linux_distribution: ('', '', '')

python: 2.6.2 (r262:71600, Jul  4 2009, 23:29:57)  [GCC 3.3.5 (propolice)]
maxunicode: 65535

platform: OpenBSD-4.6-amd64-Genuine_Intel-R-_CPU_000_@_2.93GHz-64bit-ELF



http://tahoe-lafs.org/buildbot/builders/Ludo NixOS-amd64

platform: Linux-2.6.32.13-x86_64-with-glibc2.2.5
python: 2.6.5 (r265:79063, Mar 23 2010, 09:42:45)  [GCC 4.4.3] , maxunicode: 65535 , stdout.encoding: None , stdin.encoding: None , filesystem.encoding: UTF-8



http://tahoe-lafs.org/buildbot/builders/MM netbsd5 i386 warp

platform: NetBSD-5.0.2-i386-32bit-ELF
linux_distribution: ('', '', '')

python: 2.6.5 (r265:79063, Jun 23 2010, 11:07:30)  [GCC 4.1.3 20080704 prerelease (NetBSD nb2 20081120)] , maxunicode: 65535

platform: NetBSD-5.0.2-i386-32bit-ELF



http://tahoe-lafs.org/buildbot/builders/FranXois lenny-armv5tel

platform: Linux-2.6.32-trunk-iop32x-armv5tel-with-debian-squeeze-sid
linux_distribution: ('debian', 'squeeze/sid', '')

python: 2.6.5+ (release26-maint, Jul  7 2010, 00:21:05)  [GCC 4.4.4]
maxunicode: 1114111

platform: Linux-debian_squeeze/sid-armv5tel-32bit_ELF



http://tahoe-lafs.org/buildbot/builders/FreeStorm CentOS5-i386

platform: Linux-2.6.18-194.8.1.el5-i686-athlon-with-redhat-5.5-Final

python: 2.4.3 (#1, Sep  3 2009, 15:37:12)  [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]
maxunicode: 1114111

platform: Linux-redhat_5.5-i686-32bit_ELF



http://tahoe-lafs.org/buildbot/builders/zooko ootles Mac-amd64 10.4

platform: Darwin-8.11.1-i386-32bit

python: 2.5.4 (release25-maint:72153M, Apr 30 2009, 12:28:20)  [GCC 4.0.1 (Apple Computer, Inc. build 5367)]
maxunicode: 65535

platform: Darwin-8.11.1-i386-32bit



http://tahoe-lafs.org/buildbot/builders/Zooko zomp Mac-amd64 10.6 py2.6

platform: Darwin-10.4.0-i386-64bit
linux_distribution: ('', '', '')

python: 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)  [GCC 4.2.1 (Apple Inc. build 5646)]
maxunicode: 65535

platform: Darwin-10.4.0-i386-64bit



http://tahoe-lafs.org/buildbot/builders/FreeStorm WinXP-x86 py2.6

platform: Windows-XP-5.1.2600-SP3
linux_distribution: ('', '', '')

python: 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
maxunicode: 65535

platform: Windows-XP-5.1.2600-SP3



http://tahoe-lafs.org/buildbot/builders/FreeStorm Win7-amd64-mingw py2.6

platform: Windows-post2008Server-6.1.7600
linux_distribution: ('', '', '')

python: 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)]
maxunicode: 65535



http://tahoe-lafs.org/buildbot/builders/Soultcer Win7-64 py2.6

platform: Windows-post2008Server-6.1.7600
linux_distribution: ('', '', '')

python: 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)]
maxunicode: 65535



http://tahoe-lafs.org/buildbot/builders/Dcoder Win7-64 py2.6

platform: Windows-post2008Server-6.1.7600
linux_distribution: ('', '', '')

python: 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)]
maxunicode: 65535

platform: Windows-post2008Server-6.1.7600
History
Date User Action Args
2010-08-12 02:32:40zookosetmessages: + msg113650
2010-08-01 01:01:22eric.araujosetdependencies: - Deprecate platform.dist() and platform.linux_distribution() functions
superseder: Deprecate platform.dist() and platform.linux_distribution() functions
stage: resolved
2008-09-23 18:10:25lemburgsetstatus: open -> closed
resolution: duplicate
messages: + msg73653
2008-09-23 17:36:38gregory.p.smithlinkissue1322 dependencies
2008-09-23 17:36:31gregory.p.smithsetkeywords: + patch
dependencies: + Deprecate platform.dist() and platform.linux_distribution() functions
2008-09-23 17:15:59zookosetfiles: + dist.patch.txt
messages: + msg73651
2008-09-23 14:12:12draghuramsetnosy: + draghuram
messages: + msg73641
2008-09-22 22:45:48zookosetfiles: + dist.patch.txt
messages: + msg73604
2008-09-22 22:18:59benjamin.petersonsetpriority: normal
assignee: lemburg
nosy: + lemburg
versions: + Python 3.1, Python 2.7, - Python 2.6, Python 2.5, Python 2.4, Python 3.0
2008-09-22 22:13:31zookocreate