| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: distro |
| 3 |
Version: 1.8.0 |
| 4 |
Summary: Distro - an OS platform information API |
| 5 |
Home-page: https://github.com/python-distro/distro |
| 6 |
Author: Nir Cohen |
| 7 |
Author-email: [email protected] |
| 8 |
License: Apache License, Version 2.0 |
| 9 |
Platform: All |
| 10 |
Classifier: Development Status :: 5 - Production/Stable |
| 11 |
Classifier: Intended Audience :: Developers |
| 12 |
Classifier: Intended Audience :: System Administrators |
| 13 |
Classifier: License :: OSI Approved :: Apache Software License |
| 14 |
Classifier: Operating System :: POSIX :: Linux |
| 15 |
Classifier: Operating System :: POSIX :: BSD |
| 16 |
Classifier: Operating System :: POSIX :: BSD :: FreeBSD |
| 17 |
Classifier: Operating System :: POSIX :: BSD :: NetBSD |
| 18 |
Classifier: Operating System :: POSIX :: BSD :: OpenBSD |
| 19 |
Classifier: Programming Language :: Python :: 3 |
| 20 |
Classifier: Programming Language :: Python :: 3 :: Only |
| 21 |
Classifier: Programming Language :: Python :: 3.6 |
| 22 |
Classifier: Programming Language :: Python :: 3.7 |
| 23 |
Classifier: Programming Language :: Python :: 3.8 |
| 24 |
Classifier: Programming Language :: Python :: 3.9 |
| 25 |
Classifier: Programming Language :: Python :: 3.10 |
| 26 |
Classifier: Topic :: Software Development :: Libraries :: Python Modules |
| 27 |
Classifier: Topic :: System :: Operating System |
| 28 |
Requires-Python: >=3.6 |
| 29 |
Description-Content-Type: text/markdown |
| 30 |
License-File: LICENSE |
| 31 |
|
| 32 |
Distro - an OS platform information API |
| 33 |
======================================= |
| 34 |
|
| 35 |
[](https://github.com/python-distro/distro/actions/workflows/ci.yaml) |
| 36 |
[](https://pypi.python.org/pypi/distro) |
| 37 |
[](https://img.shields.io/pypi/pyversions/distro.svg) |
| 38 |
[](https://codecov.io/github/python-distro/distro?branch=master) |
| 39 |
[](https://pypi.python.org/pypi/distro) |
| 40 |
[](http://distro.readthedocs.io/en/latest/) |
| 41 |
[](https://gitter.im/python-distro/distro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
| 42 |
|
| 43 |
`distro` provides information about the |
| 44 |
OS distribution it runs on, such as a reliable machine-readable ID, or |
| 45 |
version information. |
| 46 |
|
| 47 |
It is the recommended replacement for Python's original |
| 48 |
[`platform.linux_distribution`](https://docs.python.org/3.7/library/platform.html#platform.linux_distribution) |
| 49 |
function (removed in Python 3.8). It also provides much more functionality |
| 50 |
which isn't necessarily Python bound, like a command-line interface. |
| 51 |
|
| 52 |
Distro currently supports Linux and BSD based systems but [Windows and OS X support](https://github.com/python-distro/distro/issues/177) is also planned. |
| 53 |
|
| 54 |
For Python 2.6 support, see https://github.com/python-distro/distro/tree/python2.6-support |
| 55 |
|
| 56 |
## Installation |
| 57 |
|
| 58 |
Installation of the latest released version from PyPI: |
| 59 |
|
| 60 |
```shell |
| 61 |
pip install distro |
| 62 |
``` |
| 63 |
|
| 64 |
Installation of the latest development version: |
| 65 |
|
| 66 |
```shell |
| 67 |
pip install https://github.com/python-distro/distro/archive/master.tar.gz |
| 68 |
``` |
| 69 |
|
| 70 |
To use as a standalone script, download `distro.py` directly: |
| 71 |
|
| 72 |
```shell |
| 73 |
curl -O https://raw.githubusercontent.com/python-distro/distro/master/src/distro/distro.py |
| 74 |
python distro.py |
| 75 |
``` |
| 76 |
|
| 77 |
``distro`` is safe to vendor within projects that do not wish to add |
| 78 |
dependencies. |
| 79 |
|
| 80 |
```shell |
| 81 |
cd myproject |
| 82 |
curl -O https://raw.githubusercontent.com/python-distro/distro/master/src/distro/distro.py |
| 83 |
``` |
| 84 |
|
| 85 |
## Usage |
| 86 |
|
| 87 |
```bash |
| 88 |
$ distro |
| 89 |
Name: Antergos Linux |
| 90 |
Version: 2015.10 (ISO-Rolling) |
| 91 |
Codename: ISO-Rolling |
| 92 |
|
| 93 |
$ distro -j |
| 94 |
{ |
| 95 |
"codename": "ISO-Rolling", |
| 96 |
"id": "antergos", |
| 97 |
"like": "arch", |
| 98 |
"version": "16.9", |
| 99 |
"version_parts": { |
| 100 |
"build_number": "", |
| 101 |
"major": "16", |
| 102 |
"minor": "9" |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
$ python |
| 108 |
>>> import distro |
| 109 |
>>> distro.name(pretty=True) |
| 110 |
'CentOS Linux 8' |
| 111 |
>>> distro.id() |
| 112 |
'centos' |
| 113 |
>>> distro.version(best=True) |
| 114 |
'8.4.2105' |
| 115 |
``` |
| 116 |
|
| 117 |
|
| 118 |
## Documentation |
| 119 |
|
| 120 |
On top of the aforementioned API, several more functions are available. For a complete description of the |
| 121 |
API, see the [latest API documentation](http://distro.readthedocs.org/en/latest/). |
| 122 |
|
| 123 |
## Background |
| 124 |
|
| 125 |
An alternative implementation became necessary because Python 3.5 deprecated |
| 126 |
this function, and Python 3.8 removed it altogether. Its predecessor function |
| 127 |
[`platform.dist`](https://docs.python.org/3.7/library/platform.html#platform.dist) |
| 128 |
was already deprecated since Python 2.6 and removed in Python 3.8. Still, there |
| 129 |
are many cases in which access to that information is needed. See [Python issue |
| 130 |
1322](https://bugs.python.org/issue1322) for more information. |
| 131 |
|
| 132 |
The `distro` package implements a robust and inclusive way of retrieving the |
| 133 |
information about a distribution based on new standards and old methods, |
| 134 |
namely from these data sources (from high to low precedence): |
| 135 |
|
| 136 |
* The os-release file `/etc/os-release` if present, with a fall-back on `/usr/lib/os-release` if needed. |
| 137 |
* The output of the `lsb_release` command, if available. |
| 138 |
* The distro release file (`/etc/*(-|_)(release|version)`), if present. |
| 139 |
* The `uname` command for BSD based distrubtions. |
| 140 |
|
| 141 |
|
| 142 |
## Python and Distribution Support |
| 143 |
|
| 144 |
`distro` is supported and tested on Python 3.6+ and PyPy and on any |
| 145 |
distribution that provides one or more of the data sources covered. |
| 146 |
|
| 147 |
This 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). |
| 148 |
|
| 149 |
|
| 150 |
## Testing |
| 151 |
|
| 152 |
```shell |
| 153 |
git clone [email protected]:python-distro/distro.git |
| 154 |
cd distro |
| 155 |
pip install tox |
| 156 |
tox |
| 157 |
``` |
| 158 |
|
| 159 |
|
| 160 |
## Contributions |
| 161 |
|
| 162 |
Pull requests are always welcome to deal with specific distributions or just |
| 163 |
for general merriment. |
| 164 |
|
| 165 |
See [CONTRIBUTIONS](https://github.com/python-distro/distro/blob/master/CONTRIBUTING.md) for contribution info. |
| 166 |
|
| 167 |
Reference implementations for supporting additional distributions and file |
| 168 |
formats can be found here: |
| 169 |
|
| 170 |
* https://github.com/saltstack/salt/blob/develop/salt/grains/core.py#L1172 |
| 171 |
* https://github.com/chef/ohai/blob/master/lib/ohai/plugins/linux/platform.rb |
| 172 |
* https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/system/distribution.py |
| 173 |
* https://github.com/puppetlabs/facter/blob/master/lib/src/facts/linux/os_linux.cc |
| 174 |
|
| 175 |
## Package manager distributions |
| 176 |
|
| 177 |
* https://src.fedoraproject.org/rpms/python-distro |
| 178 |
* https://www.archlinux.org/packages/community/any/python-distro/ |
| 179 |
* https://launchpad.net/ubuntu/+source/python-distro |
| 180 |
* https://packages.debian.org/stable/python3-distro |
| 181 |
* https://packages.gentoo.org/packages/dev-python/distro |
| 182 |
* https://pkgs.org/download/python3-distro |
| 183 |
* https://slackbuilds.org/repository/14.2/python/python-distro/ |