I want to include some kind of self-update mechanism on a python package and I do not want to call pip update before the script is run as it is very slow, I am looking for a smart mechanism.
Every time it is used it could make an HTTP call, probably to PyPi and if it would detect a new version it would output a warning on STDERR.
Obviously, as part of this process I would also want to cache the result of last call, so the library would not check for updates more than once a day, let say.
Does anyone has something like this already implemented? Do you have an example that can be used to cache results from HTTP calls, between different executions, so it would not impose signifiant delays?
I've written a library
outdated
to solve this problem. The quickest way to use it is to insert code like this somewhere at the root of your package:This will output a warning on stderr as requested, cache the HTTP call for 24 hours, and more. Details can be found in the link above.
It's also much faster than
pip list -o
even without caching.