Skip to content

Issue 33393 - #33396

Merged
cachedout merged 2 commits into
saltstack:2015.8from
wwentland:issue-33393
Jun 1, 2016
Merged

cachedout merged 2 commits into
saltstack:2015.8from
wwentland:issue-33393

Conversation

@wwentland

@wwentland wwentland commented May 20, 2016 •

Copy link
Copy Markdown
Contributor

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.

Byron Clark and others added 2 commits May 20, 2016 12:30
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.
@tmehlinger

tmehlinger commented May 20, 2016 •

Copy link
Copy Markdown
Contributor

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.

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.

@wwentland

Copy link
Copy Markdown
Contributor Author

Yeah, but I don't really see what it buys us in this case. All we really care about is that InstallationError is defined as either pip.exceptions.InstallationError for recent pip versions or, if that can't be found, as ValueError.

Trying to import pip.exceptions.InstallationError and then falling back to ValueError seems to achieve exactly that.

If you can think of some advantages we can give being more explicit a try, but this seems to fix the actual problem.

@UtahDave

Copy link
Copy Markdown
Contributor

Go Go Jenkins!

@thatch45

Copy link
Copy Markdown
Contributor

Given the pip changes, I would actually lean towards moving this logic into utils so that we just don't import pip anymore.

@thatch45

Copy link
Copy Markdown
Contributor

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

@cachedout cachedout added the pending-discussion The issue or pull request needs more discussion before it can be closed or merged label May 24, 2016
@wwentland

Copy link
Copy Markdown
Contributor Author

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.

@thatch45

Copy link
Copy Markdown
Contributor

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:
a) reimpliment the code from pip that we need in salt/utils so that we never import pip
b) shell out to get the data so that we never import pip

I like a more, but would take the easier approach, my main worry is that if we merge this it might break pip for versions greater that 8 again

@wwentland

wwentland commented May 25, 2016 •

Copy link
Copy Markdown
Contributor Author

Sure, but we don't know what will happen post 8.0 and this fixes pip.installed on wheezy in the interim. I'm all for "doing it right"™, but this fixes a regression that was introduced in a point release in a way that I think is less likely to break than the current approach. (which is broken)

@thatch45

Copy link
Copy Markdown
Contributor

I understand that, let me test this change with running new versions of pip to see if this can hold us over for now

@cachedout

Copy link
Copy Markdown
Contributor

Bump @thatch45

@thatch45

thatch45 commented Jun 1, 2016

Copy link
Copy Markdown
Contributor

Sorry about being slow on this, all of this looks good, lets merge it in!

@cachedout
cachedout merged commit 13537c4 into saltstack:2015.8 Jun 1, 2016
@wwentland
wwentland deleted the issue-33393 branch June 1, 2016 21:32
@rallytime

Copy link
Copy Markdown
Contributor

Back-ports #31027 to 2015.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-discussion The issue or pull request needs more discussion before it can be closed or merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants