-
Notifications
You must be signed in to change notification settings - Fork 67
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
Encourage using feature detection instead of distro name/version #221
Comments
completely agreed with that. Use it carefully if you need to. But better try to make decisions on features found. |
While I definitely agree we should add a warning, I disagree that we should state that it shouldn't be used to make decisions. Rather, I think it makes sense to state that "It should be used to make decisions only if it makes sense". A for instance: Cloudify uses Wagon to build their plugin packages. Packages that contain C extensions are compiled for a specific distribution and is expected to run on that distribution and only if the distribution contains the exact glibc (etc) as the build environment. What I do agree with, is that "Using the distribution info to decide on things reduces precision. If you care about precision, go for a lower-level decision-making algorithm". WDYT? |
That is exactly what forces Ubuntu derivatives to identify as Ubuntu (and optionally publishing their “true name” in a non-standard location, which will in turn force |
The particular derivative case is solved by Debian by using |
That looks like a distro-specific solution, which requires a special case in the detection code 🙁 |
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 |
@encukou, I'd appreciate it if you proposed the wording for the wording. Also, where do you think the warning should go? |
Sorry for the delay. Preferring feature detectionInformation from this package is useful for logging and problem reporting. However, it is usually a bad idea to base automated decisions on the If people use distro to apply custom workarounds for, say, Ubuntu, |
But what does I believe this scope problem is also the main reason for removing |
On Fri, Apr 12, 2019 at 07:30:32AM -0700, Petr Viktorin wrote:
@basak
> [...] But `os-release` does have `ID_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.
But what does `ID_LIKE` mean? In what respect is the distro *like* another distro?
If I take Ubuntu, re-package it all into RPM, and put in `yum` instead of `apt-get`, should I label it as “like Ubuntu”?
I don't think it needs to specify crazy situations and cover all cases
before it can be useful. If you're going to make such invasive changes
in your derivative, then you'll need to patch things all over the place
to accomodate differing behaviour anyway. At that point, you might as
well add specific behaviour for the new scenario in those patches anyway
(and send them upstream etc).
In the majority of cases, something like "like Debian" will do, and
automatically incorporate Ubuntu and Mint.
FWIW, the specification of ID_LIKE is in here:
https://www.freedesktop.org/software/systemd/man/os-release.html
I believe this scope problem is also the main reason for removing `platform.linux_distribution()` from Python: We don't know the questions we are trying to answer. Or, we're trying to give a single answer to too many questions at once.
Related are my comments and their replies at
https://bugs.python.org/issue28167. This isn't a problem that the Python
world needs to solve alone. The Free Software community has converged on
os-release, and it would be very useful to at least pass that through in
a Pythonic way. Extra smarts is fine, but it only really needs to be
added on as an opt-in now, or used where (presumably only obscure
distributions now when) os-release isn't available.
I'm not suggesting that feature detection is wrong; it certainly is the
most granular and future-proof way of solving the general problem. I'm
only saying that it can be difficult to do right in some cases, and in
those cases would be overkill when ID_LIKE would suffice - if only there
were a library that allowed Python developers to do that test easily in
one line.
|
Oh, nothing against quick hacks! But I'd like to make sure people know what the proper solution is. |
Hello! I'm the person responsible for dropping
platform.linux_distrubution
from Python 3.8. We're now recommendingdistro
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:
You'll find warnings against using browser-agent in any respectable recent documentation on the topic.
The text was updated successfully, but these errors were encountered: