Given the name of a Python (2.X) package that can be installed with pip and virtualenv, is there any way to find out a list of all the possible versions of it that pip could install? Right now it's trial and error.
I'm trying to install a version for a third party library, but the newest version is too new, there were backwards incompatible changes made. So I'd like to somehow have a list of all the versions that pip knows about, so that I can test them.
My take is a combination of a couple of posted answers, with some modifications to make them easier to use from within a running python environment.
The idea is to provide a entirely new command (modeled after the install command) that gives you an instance of the package finder to use. The upside is that it works with, and uses, any indexes that pip supports and reads your local pip configuration files, so you get the correct results as you would with a normal pip install.
I've made an attempt at making it compatible with both pip v 9.x and 10.x.. but only tried it on 9.x
https://gist.github.com/kaos/68511bd013fcdebe766c981f50b473d4
Example output
Here's the current Python pip-based method, searching the legacy PyPi package API:
I know this is kind of silly but you can try something like this:
This will error out but will list all the versions that are available for this package.
Just replace
django
with the package you want and also I believe, hopefully, there is no such version called x.I didn't have any luck with
yolk
,yolk3k
orpip install -v
but so I ended up using this (adapted to Python 3 from eric chiang's answer):Pip 7.1.0 has removed --no-install option from install. I found a method to get all versions of a package without any extra package.
After looking at pip's code for a while, it looks like the code responsible for locating packages can be found in the
PackageFinder
class inpip.index
. Its methodfind_requirement
looks up the versions of aInstallRequirement
, but unfortunately only returns the most recent version.The code below is almost a 1:1 copy of the original function, with the return in line 114 changed to return all versions.
The script expects one package name as first and only argument and returns all versions.
http://pastebin.com/axzdUQhZ
I can't guarantee for the correctness, as I'm not familiar with pip's code. But hopefully this helps.
Sample output
The code: