Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

carljm opened this Issue Dec 12, 2011 · 6 comments


None yet
3 participants

carljm commented Dec 12, 2011

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 commented Feb 28, 2013

@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 commented Feb 28, 2013

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


carljm commented Feb 28, 2013

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 commented Feb 28, 2013

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 commented Feb 28, 2013

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 commented Sep 18, 2013

made this change here: 44323cd

@qwcode qwcode closed this Sep 18, 2013

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