Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't use pkg_resources for reporting version with "pip --version" #401

Closed
carljm opened this Issue · 6 comments

3 participants

@carljm
Owner

Currently, pip relies on pkg_resources.get_distribution('pip') to report what version of pip is installed, and where, when you run pip --version. Unfortunately, this sometimes does not provide a useful answer (e.g. when running a pip that is not "installed"), and sometimes provides an entirely wrong answer (when there is an installed pip, but there is also a not-installed pip package that is higher on sys.path than the installed one - in this case the latter one will actually be run, but --version will report the installed one).

It would be better if we used a simpler technique, like import pip; pip.__file__ to report which pip is running and from what location. For version, this would require introducing a pip.__version__ attribute (in which case we should probably also parse that for use in setup.py and docs/conf.py).

@qwcode
Owner

@carljm , we have pip.__version__ now, but I've always found it acceptable (and valid) that I should have to run setup.py develop to expect the version to report correctly. this is really only relevant for pip development, right? who else would have layers of pip packages on their sys.path?

@qwcode
Owner

otoh, I guess you really want pip to tell you what it's really executing, not what is "properly" installed.

@carljm
Owner

I think this is most likely to be relevant for pip developers, yes, although I think there are other situations where it may come up. It just seems kind of obvious that it's better for pip --version to reliably report the version of the code that's actually executing. If I want to know what's installed I'll run pip freeze.

@pfmoore
Owner

I would definitely expect to see the version of the running pip, not the installed one (if there were a difference, which I concede is unlikely). Also, getting a version attribute is far simpler than invoking pkg_resources, which is something I think is worthwhile in any case.

@qwcode
Owner

the change will involve some minor code shuffle due to circular import issues.
also, test_basic:test_correct_pip_version would need to be fixed after changing this.

@qwcode
Owner

made this change here: 44323cd

@qwcode qwcode closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.