• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

distro.egg-info/H03-May-2022-170128

docs/H30-Jul-2021-546367

tests/H30-Jul-2021-3,1332,448

CHANGELOG.mdH A D30-Jul-20218.2 KiB194136

CONTRIBUTING.mdH A D30-Jul-20212.2 KiB5442

CONTRIBUTORS.mdH A D30-Jul-2021393 1513

LICENSEH A D30-Jul-202111.1 KiB203169

MANIFEST.inH A D30-Jul-2021143 139

MakefileH A D30-Jul-20212.5 KiB9360

PKG-INFOH A D30-Jul-20216.4 KiB170128

README.mdH A D30-Jul-20215.1 KiB13697

distro.pyH A D30-Jul-202147.3 KiB1,387976

query_local_distro.pyH A D03-May-20221.6 KiB4624

setup.cfgH A D30-Jul-20211.4 KiB5446

setup.pyH A D30-Jul-2021613 182

README.md

1Distro - an OS platform information API
2=======================================
3
4[![CI Status](https://github.com/python-distro/distro/workflows/CI/badge.svg)](https://github.com/python-distro/distro/actions/workflows/ci.yaml)
5[![PyPI version](http://img.shields.io/pypi/v/distro.svg)](https://pypi.python.org/pypi/distro)
6[![Supported Python Versions](https://img.shields.io/pypi/pyversions/distro.svg)](https://img.shields.io/pypi/pyversions/distro.svg)
7[![Code Coverage](https://codecov.io/github/python-distro/distro/coverage.svg?branch=master)](https://codecov.io/github/python-distro/distro?branch=master)
8[![Is Wheel](https://img.shields.io/pypi/wheel/distro.svg?style=flat)](https://pypi.python.org/pypi/distro)
9[![Latest Github Release](https://readthedocs.org/projects/distro/badge/?version=stable)](http://distro.readthedocs.io/en/latest/)
10[![Join the chat at https://gitter.im/python-distro/distro](https://badges.gitter.im/python-distro/distro.svg)](https://gitter.im/python-distro/distro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
11
12`distro` provides information about the
13OS distribution it runs on, such as a reliable machine-readable ID, or
14version information.
15
16It is the recommended replacement for Python's original
17[`platform.linux_distribution`](https://docs.python.org/3.7/library/platform.html#platform.linux_distribution)
18function (removed in Python 3.8). It also provides much more functionality
19which isn't necessarily Python bound, like a command-line interface.
20
21Distro currently supports Linux and BSD based systems but [Windows and OS X support](https://github.com/python-distro/distro/issues/177) is also planned.
22
23For Python 2.6 support, see https://github.com/python-distro/distro/tree/python2.6-support
24
25## Installation
26
27Installation of the latest released version from PyPI:
28
29```shell
30pip install distro
31```
32
33Installation of the latest development version:
34
35```shell
36pip install https://github.com/python-distro/distro/archive/master.tar.gz
37```
38
39
40## Usage
41
42```bash
43$ distro
44Name: Antergos Linux
45Version: 2015.10 (ISO-Rolling)
46Codename: ISO-Rolling
47
48$ distro -j
49{
50    "codename": "ISO-Rolling",
51    "id": "antergos",
52    "like": "arch",
53    "version": "16.9",
54    "version_parts": {
55        "build_number": "",
56        "major": "16",
57        "minor": "9"
58    }
59}
60
61
62$ python
63>>> import distro
64>>> distro.linux_distribution(full_distribution_name=False)
65('centos', '7.1.1503', 'Core')
66```
67
68
69## Documentation
70
71On top of the aforementioned API, several more functions are available. For a complete description of the
72API, see the [latest API documentation](http://distro.readthedocs.org/en/latest/).
73
74## Background
75
76An alternative implementation became necessary because Python 3.5 deprecated
77this function, and Python 3.8 removed it altogether. Its predecessor function
78[`platform.dist`](https://docs.python.org/3.7/library/platform.html#platform.dist)
79was already deprecated since Python 2.6 and removed in Python 3.8. Still, there
80are many cases in which access to that information is needed. See [Python issue
811322](https://bugs.python.org/issue1322) for more information.
82
83The `distro` package implements a robust and inclusive way of retrieving the
84information about a distribution based on new standards and old methods,
85namely from these data sources (from high to low precedence):
86
87* The os-release file `/etc/os-release` if present, with a fall-back on `/usr/lib/os-release` if needed.
88* The output of the `lsb_release` command, if available.
89* The distro release file (`/etc/*(-|_)(release|version)`), if present.
90* The `uname` command for BSD based distrubtions.
91
92
93## Python and Distribution Support
94
95`distro` is supported and tested on Python 2.7, 3.4+ and PyPy and on
96any distribution that provides one or more of the data sources
97covered.
98
99This package is tested with test data that mimics the exact behavior of the data sources of [a number of Linux distributions](https://github.com/python-distro/distro/tree/master/tests/resources/distros).
100
101
102## Testing
103
104```shell
105git clone git@github.com:python-distro/distro.git
106cd distro
107pip install tox
108tox
109```
110
111
112## Contributions
113
114Pull requests are always welcome to deal with specific distributions or just
115for general merriment.
116
117See [CONTRIBUTIONS](https://github.com/python-distro/distro/blob/master/CONTRIBUTING.md) for contribution info.
118
119Reference implementations for supporting additional distributions and file
120formats can be found here:
121
122* https://github.com/saltstack/salt/blob/develop/salt/grains/core.py#L1172
123* https://github.com/chef/ohai/blob/master/lib/ohai/plugins/linux/platform.rb
124* https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py
125* https://github.com/puppetlabs/facter/blob/master/lib/src/facts/linux/os_linux.cc
126
127## Package manager distributions
128
129* https://src.fedoraproject.org/rpms/python-distro
130* https://www.archlinux.org/packages/community/any/python-distro/
131* https://launchpad.net/ubuntu/+source/python-distro
132* https://packages.debian.org/sid/python-distro
133* https://packages.gentoo.org/packages/dev-python/distro
134* https://pkgs.org/download/python2-distro
135* https://slackbuilds.org/repository/14.2/python/python-distro/
136