pypi - How can I safely check if a python package is outdated? -
i want include kind of self-update mechanism on python package , not want call pip update before script run slow, looking smart mechanism.
every time used make http call, pypi , if detect new version output warning on stderr.
obviously, part of process want cache result of last call, library not check updates more once day, let say.
does has implemented? have example can used cache results http calls, between different executions, not impose signifiant delays?
to show outdated packages can run pip list -o
, doesn't involve caching itself.
although trivial add pip list -o > outdated.txt
cronjob automatically updates daily :)
here's example code use pip
library:
def get_outdated(): import pip list_command = pip.commands.list.listcommand() options, args = list_command.parse_args([]) packages = pip.utils.get_installed_distributions() return list_command.get_outdated(packages, options) print(get_outdated())
Comments
Post a Comment