Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform.dist(): detect Linux distribution version in a robust, standard way #48187

Closed
zooko mannequin opened this issue Sep 22, 2008 · 6 comments
Closed

platform.dist(): detect Linux distribution version in a robust, standard way #48187

zooko mannequin opened this issue Sep 22, 2008 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@zooko
Copy link
Mannequin

zooko mannequin commented Sep 22, 2008

BPO 3937
Nosy @malemburg
Superseder
  • bpo-1322: Deprecate platform.dist() and platform.linux_distribution() functions
  • Files
  • dist.patch.txt: patch to platform.dist() to execute lsb_release
  • dist.patch.txt
  • dist.patch.txt
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/malemburg'
    closed_at = <Date 2008-09-23.18:10:25.169>
    created_at = <Date 2008-09-22.22:13:31.761>
    labels = ['type-bug', 'library']
    title = 'platform.dist(): detect Linux distribution version in a robust, standard way'
    updated_at = <Date 2010-08-12.02:32:40.102>
    user = 'https://bugs.python.org/zooko'

    bugs.python.org fields:

    activity = <Date 2010-08-12.02:32:40.102>
    actor = 'zooko'
    assignee = 'lemburg'
    closed = True
    closed_date = <Date 2008-09-23.18:10:25.169>
    closer = 'lemburg'
    components = ['Library (Lib)']
    creation = <Date 2008-09-22.22:13:31.761>
    creator = 'zooko'
    dependencies = []
    files = ['11562', '11563', '11573']
    hgrepos = []
    issue_num = 3937
    keywords = ['patch']
    message_count = 6.0
    messages = ['73601', '73604', '73641', '73651', '73653', '113650']
    nosy_count = 3.0
    nosy_names = ['lemburg', 'zooko', 'draghuram']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1322'
    type = 'behavior'
    url = 'https://bugs.python.org/issue3937'
    versions = ['Python 3.1', 'Python 2.7']

    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented Sep 22, 2008

    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".

    @zooko zooko mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 22, 2008
    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented Sep 22, 2008

    Here's a new version of this patch which differs only in having slightly
    more correct documentation.

    @draghuram
    Copy link
    Mannequin

    draghuram mannequin commented Sep 23, 2008

    Please take a look at bpo-1322 for some discussion on this topic.

    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented Sep 23, 2008

    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.

    @malemburg
    Copy link
    Member

    As explained in bpo-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 bpo-1322.

    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented Aug 12, 2010

    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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant