platform.linux_distribution was deprecated in 2015 to be removed in
Python 3.7 [1,2]. And it may not exist at all on some Python builds
(Manjaro's [3]?). Prefer distro (the replacement PyPI package [4,5])
on Linux if the user already has it installed.
If we can't find a distro/version, use '*' for generic help-URL
matching. And silently skip distro/version information in
print_system_info.
[1]: http://bugs.python.org/issue1322#msg243063
[2]: https://docs.python.org/3/library/platform.html#platform.linux_distribution
[3]: https://github.com/prerit2010/swc-setup-installation-test/issues/7#issuecomment-
231573710
[4]: http://bugs.python.org/issue1322#msg263896
[5]: https://pypi.python.org/pypi/distro
import urllib as _urllib_parse # for quote()
import xml.etree.ElementTree as _element_tree
import urllib as _urllib_parse # for quote()
import xml.etree.ElementTree as _element_tree
+try:
+ import distro as _distro
+except ImportError:
+ _distro = None
+
if not hasattr(_shlex, 'quote'): # Python versions older than 3.3
# Use the undocumented pipes.quote()
if not hasattr(_shlex, 'quote'): # Python versions older than 3.3
# Use the undocumented pipes.quote()
def get_url(self):
system = _platform.system()
version = None
def get_url(self):
system = _platform.system()
version = None
- for pversion in (
- 'linux_distribution',
- 'mac_ver',
- 'win32_ver',
- ):
- value = getattr(_platform, pversion)()
- if value[0]:
- version = value[0]
+ if system == 'Linux' and _distro:
+ version = _distro.id()
+ else:
+ for pversion in (
+ 'linux_distribution',
+ 'mac_ver',
+ 'win32_ver',
+ ):
+ value = getattr(_platform, pversion)()
+ if value[0]:
+ version = value[0]
+ if not version:
+ version = '*'
package = self.checker.name
for (s,v,p),url in self._setup_urls.items():
if (_fnmatch.fnmatch(system, s) and
package = self.checker.name
for (s,v,p),url in self._setup_urls.items():
if (_fnmatch.fnmatch(system, s) and
_print_info('os.uname', _platform.uname())
_print_info('platform', _sys.platform)
_print_info('platform+', _platform.platform())
_print_info('os.uname', _platform.uname())
_print_info('platform', _sys.platform)
_print_info('platform+', _platform.platform())
+ system = _platform.system()
+ if system == 'Linux' and _distro:
+ _print_info(
- 'mac_ver',
- 'win32_ver',
- ):
- value = getattr(_platform, pversion)()
- if value[0]:
- _print_info(pversion, value)
+ _distro.name(pretty=True) or _distro.linux_distribution())
+ else:
+ for pversion in (
+ 'linux_distribution',
+ 'mac_ver',
+ 'win32_ver',
+ ):
+ value = getattr(_platform, pversion)()
+ if value[0]:
+ _print_info(pversion, value)
_print_info('prefix', _sys.prefix)
_print_info('exec_prefix', _sys.exec_prefix)
_print_info('executable', _sys.executable)
_print_info('prefix', _sys.prefix)
_print_info('exec_prefix', _sys.exec_prefix)
_print_info('executable', _sys.executable)