I would like to see this as an option to upgrade and upgrade-all, where in the case of the former it would tell you if an upgrade is available for the given package, and in the latter it would list the packages for which an upgrade is available
Maybe an option like --dry-run?
Yes, that would work
I started implementing this using pip search PACKAGE, but it does not do exact matching, nor can it (https://github.com/pypa/pip/issues/3354). If there is an API pipx can use, I am happy to add it.
Another way to implement this would be to install to a temporary directory, get the version, then erase the temporary directory, but I am going to hold off on that.
Hmm, I didn't realise pip search was so fraught with troubles. And it seems they may even consider disabling it in the future (pypa/pip#5216) without a better API powering it
It seems that running pip install <name>== will prompt an error message (because a version number is missing after the ==) containing a list of versions which are available. Eg,
$ pip3 install pipx==
Collecting pipx==
Could not find a version that satisfies the requirement pipx== (from versions: 0.1.0, 0.12.0.0, 0.12.0.1, 0.12.0.2, 0.12.0.3, 0.12.0.4, 0.12.1.0, 0.12.2.0, 0.12.3.0, 0.12.3.1, 0.12.3.2, 0.12.3.3, 0.13.0.0b1, 0.13.0.0, 0.13.0.1, 0.13.1.0)
No matching distribution found for pipx==
Would parsing this output be acceptable for finding the latest available version of a package?
Studying the debug output of pip, it appears this is internally implemented by analysing the links on the page https://pypi.python.org/simple/<name>/ eg https://pypi.python.org/simple/pipx/
Looks like this url will work:
Not sure if it will be of much use to others, but I wrote a proof-of-concept bash function that does the job well enough, if not very elegantly.
I use this on a machine with Bash4.4 and GNU coreutils, but I don't think I used anything that wont also work with the BSD counterparts.
pipx-outdated() {
echo "OUTDATED PACKAGES:"
while read -sr pyPkgName pyPkyVersion; do
local pypi_latest="$(curl -sS https://pypi.org/simple/${pyPkgName}/ | grep -o '>.*</' | tail -n 1 | grep -o -E '[0-9]([0-9]|[-._])*[0-9]')"
[ "$pyPkyVersion" != "$pypi_latest" ] && printf "%s\n\tCurrent: %s\tLatest: %s\n" "$pyPkgName" "$pyPkyVersion" "$pypi_latest"
done < <( pipx list | grep -o 'package.*,' | tr -d ',' | cut -d ' ' -f 2- )
}
The underlying technical necessity here is the same as #464.
Yes, code that leverages the pip Simple API is probably the way to go for specific searches. It's a shame the return is in HTML instead of some more data-oriented format, but as mentioned in #464 there are python libraries to help parse the html to usable data. I'm not sure which of them is the best and/or actively-developed.
e.g. https://github.com/jwodder/pypi-simple, an interface to the Simple API
https://discuss.python.org/t/potential-inconsistency-w-pep-503-simple-repo-api/3571/4
The quote:
That鈥檚 correct, pretty much nothing uses /simple/ as far as I鈥檓 aware. It鈥檚 huge and also doesn鈥檛 get purged regularly so it鈥檚 usually out of date anyways.
seems a little worrying to me to use the Simple API as a trusted reference.
The simple API is a trusted source. The comment you鈥檙e referencing is taking about the /simple/ page specifically, which lists all packages on an index, that is not relevant here.
Oh, I thought they came from the same place.