How do you check if a package is at its latest version programmatically in a script and return a true or false?
I can check with a script like this:
My project luddite has this feature:
>>> import luddite
>>> luddite.get_version_pypi("gekko")
'0.2.3'
The canonical way to check installed version is just to access the __version__
attribute of the top-level namespace:
>>> import gekko
>>> gekko.__version__
'0.2.0'
Unfortunately not all projects set this attribute. When they don't, you can use pkg_resources
to dig it out from the metadata:
>>> import pkg_resources
>>> pkg_resources.get_distribution("gekko").version
'0.2.0'