Repository navigation
Issue 33393 - #33396
Issue 33393#33396
Conversation
This check exists twice in the code. Once is good enough for anyone.
The way the version check was implemented fails on ancient pip versions that do not provide pip.__version__ yet. We will therefore simply try to import InstallationError and fall back to ValueError if it has not been defined in the installed pip version.
I'd lean toward the former. Given how substantially pip has changed between some versions, I think the best approach is to import, check the version, then execute a code path specifically for that version. ... which is going to be a lot of work, but arguably better than the pip state blowing up with updates for every minor change in pip. |
|
Yeah, but I don't really see what it buys us in this case. All we really care about is that Trying to import If you can think of some advantages we can give being more explicit a try, but this seems to fix the actual problem. |
|
Go Go Jenkins! |
|
Given the pip changes, I would actually lean towards moving this logic into utils so that we just don't import pip anymore. |
|
Basically, the pip api is not stable and we should not use it at all, we should do something like shell out to get the version of pip. Basically pip will keep breaking so long as we import it |
|
I would happily consider a different approach. Could you elaborate on what you have in mind, @thatch45 ? Just tried to get it working again to begin with and think that this PR still improves the code as it is. But then you are probably right that one shouldn't rely too much on a stable pip API and use a different approach. |
|
right, and this has been a complete mine field, because the api changes so much over pip versions. So the question is, what do we use the api for? and can we either: I like |
|
Sure, but we don't know what will happen post 8.0 and this fixes |
|
I understand that, let me test this change with running new versions of pip to see if this can hold us over for now |
|
Bump @thatch45 |
|
Sorry about being slow on this, all of this looks good, lets merge it in! |
|
Back-ports #31027 to 2015.8 |
What does this PR do?
This PR fixes a broken pip version check that was introduced in 2015.8.4 and also contains a backport of a commit by @byronclark from develop in which duplicated code was removed.
What issues does this PR fix or reference?
#33393
Tests written?
No
It should be noted that I am not sure if this is the best way to deal with this problem. Maybe it would make sense to test for the existence of
pip.__version__explicitly, but optimistic imports with exception handling might not be a bad idea.