Encourage using feature detection instead of distro name/version
See original GitHub issueHello! I’m the person responsible for dropping platform.linux_distrubution
from Python 3.8. We’re now recommending distro
instead. Thank you for all the work going into this module – it’s certainly useful in certain cases, like finding out what to put in a log or problem report.
However, think that distro
’s docs should include a warning against using it for decisions, because a platform’s name is not a good indicator of what is possible on it.
Once people apply custom workarounds for Ubuntu (and use distro info for that), less popular derivatives like Linux Mint will need to report themselves as Ubuntu to get those workarounds. That then leads to the need for better distro reporting tools, like this one… which then leads to more distro-specific workarounds. It’s a vicious circle.
It’s the same problem as “browser sniffing” in the web world, where modern “user agent” strings contain mostly lies:
Mozilla/5.0 (Linux; Android 4.4.2); Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36 OPR/20.0.1396.72047
You’ll find warnings against using browser-agent in any respectable recent documentation on the topic.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
Sorry for the delay. Would the following work for the documentation, under Overview and motivation?
Preferring feature detection
Information from this package is useful for logging and problem reporting.
However, it is usually a bad idea to base automated decisions on the information. Instead, try to use feature detection. If you need to install packages, look for
yum
vs.apt-get
commands, if you need a specific version ofglibc
, query the library version directly, and so on.If people use distro to apply custom workarounds for, say, Ubuntu, less popular derivatives like Linux Mint will need to report themselves as Ubuntu to get those workarounds. That then leads to the need for more powerful distro reporting tools, which then leads to more distro-specific workarounds, and more distros needing to pose as other distros to get the workarounds. Please, do not feed the vicious circle.
I just mentioned it as an example of how the problem is solved today. I didn’t intend to suggest that you used that as-is. But
os-release
does haveID_LIKE
, which provides the information you need to implement something similar. I think you could implement a “am I like X” function using that data.