-
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
Fixing how distro deals with inconsistent *-release files. #178
Fixing how distro deals with inconsistent *-release files. #178
Conversation
This is cool and certainly will allow us to solve some inconsistencies but will also somewhat pollute the code as we find more and more inconsistent implementations because it changes the default implementation in the base class. My idea is to write a class per inconsistent distribution which will inherit So, for instance, in Linux Mint's use case, the method under Any main method in the base classe ( Should I provide an example, or is that clear? Also, instead, it's possible to create a function which would identify all inconsistencies and return a class (inheriting |
An example: replace:
with: class Centos7(LinuxDistribution):
def codename(self):
return 'Ridiculous'
def version(self, pretty=False, best=False):
return '7.9'
def _get_implementation():
original = LinuxDistribution()
if original.id() == 'centos' and original.version() == '7':
return Centos7()
return LinuxDistribution()
_distro = _get_implementation() $ distro -j
{
"codename": "Ridiculous",
"id": "centos",
"like": "rhel fedora",
"version": "7.9",
"version_parts": {
"build_number": "",
"major": "7",
"minor": "9"
}
} I think it's a very clean solution and wonderfully easy for developers to support. It also allows you to use whatever method you want from the base class to parse files or change specific implementations. WDYT? |
I agree completely on the solution. This PR was more to be exploratory and to spark discussion. :) My only concern is that now developers can't just call |
Why not?
…On Apr 2, 2017 5:43 PM, "Seth M. Larson" ***@***.***> wrote:
I agree completely on the solution. This PR was more to be exploratory and
to spark discussion. :) My only concern is that now developers can't just
call LinuxDistribution to get the proper object to describe their system
like they could in the past.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#178 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB6QhMX8y-GEZWZ8MUnJo1sC1tST-Q60ks5rr7QJgaJpZM4MwouJ>
.
|
If they do on a system with inconsistencies they won't receive |
Oh you mean if their distribution has inconsistencies. True.
…On Apr 2, 2017 5:48 PM, "Nir Cohen" ***@***.***> wrote:
Why not?
On Apr 2, 2017 5:43 PM, "Seth M. Larson" ***@***.***> wrote:
> I agree completely on the solution. This PR was more to be exploratory
> and to spark discussion. :) My only concern is that now developers can't
> just call LinuxDistribution to get the proper object to describe their
> system like they could in the past.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#178 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AB6QhMX8y-GEZWZ8MUnJo1sC1tST-Q60ks5rr7QJgaJpZM4MwouJ>
> .
>
|
So I currently see two ways of dealing with it, I'm sure there's more but here's the two I could think of. One more transparent but also breaks functionality in the case that anyone is subclassing the We could rename We could make As crazy as it sounds I think I'm more in favor of option number 1, even though it would necessitate a major version bump... |
And if you think about it option 1 lends itself well to if and when we decide to implement Windows and Mac OS functionality. Have a single function |
While I agree that it would be "safer" to fork the class to a function, it would also be misleading and non-future-proof. While distro isn't that much widely used, I'd rather release a major version breaking the previous one and explicitly stating that it breaks stuff in BIG RED :) Using We can say something like: By default, you can still use
Yes, it breaks backwards, but I'd release distro 2.0 for that to be so clean. Also, I don't think it neglects the idea of Windows and OSx. Users will still use |
The name is fine with me! Sounds good. :) Question is do we throw Windows and Mac compatibility into v2 as well so we don't have two major releases? |
I think so. Makes sense.. But maybe we should get some more feedback about win and osx support? |
@nir0s I'd love some feedback. :) Do we have an opinion from any upstream like pip? |
@dstufft? @xavfernandez? @andy-maier? Your input? |
Just an FYI to reviewers first reading this PR: This PR isn't what needs review. Just need feedback on adding Windows/OSX and the proposed method of mitigating Linux distro inconsistencies by @nir0s :) Thanks! |
Since we're talking about parts here as well as in another issue I'll reference it: #177 |
Concerning pip, the only place we are using |
I guess we can start working on the proposed solution and keep discussing additional OS related stuff in the dedicated issue. |
That sounds good to me, I'll start a little work on a v2 branch and we can take it from there. |
So this PR is a minimal (and IMO rather hacky) solution to the two cases where distro has trouble with getting the right information from *-release files. The two related issues are #78 for Linux Mint and #152 for Debian stretch/sid when lsb-release isn't installed. I don't think this solution should be merged, might be a good place for some discussion about the proper direction.
If I were to be able to make more changes it might be nice to have
distro.LinuxDistribution()
do all it's parsing, assigns values, and then return a class that does minimal logic and spits out those values when they're queried. Could still keep same interface includingos_release_attr
,lsb_release_attr
, etc. Would allow for a cleaner layout of where special cases happen rather than have each special case occur within theid()
,codename()
andversion()
functions. I think this would be a much better route to go, especially for when future inconsistencies are found.Thoughts?