15 Aug
2009
15 Aug
'09
2:54 p.m.
Hanno Schlichting wrote:
The easiest way I could find right now seems to be:
import pkg_resources dist = pkg_resources.get_distribution('foo') dist.version 3.2.1
Which isn't too bad and could be simplified into an even simpler API call.
If the package author doesn't set a __version__ attribute in his own code, I'd be hesitant to magically make it available from the accompanying metadata. If it's part of the metadata, an explicit API that makes it clear that you are querying the package metadata seems cleaner to me.
+1 to all of this... Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk