[Python-Dev] PEP 396, Module Version Numbers
Barry Warsaw
barry at python.org
Tue Apr 12 20:49:52 CEST 2011
On Apr 07, 2011, at 12:10 PM, Michael Foord wrote:
>>> On 4/5/2011 11:52 AM, Barry Warsaw wrote:
>>>
>>> DEFAULT_VERSION_RE = re.compile(r'(?P<version>\d+\.\d(?:\.\d+)?)')
>>>
>>> __version__ = pkgutil.get_distribution('elle').metadata['version']
>>>
>
>I really dislike this way of specifying the version. For a start it is really
>ugly.
Agreed! There should be a higher level API for this, e.g.:
__version__ = pkgutil.get_version('elle')
>More importantly it means the version information is *only* available if the
>package has been installed by "packaging", and so isn't available for the
>parts of my pre-build process like building the documentation (which import
>the version number to put into the docs).
That would have to be an important feature of .get_version() I think.
>Currently all my packages have the canonical version number information in
>the package itself using:
>
> __version__ = '1.2.3'
>
>Anything that needs the version number, including setup.py for upload to
>pypi, has one place to look for it and it doesn't depend on any other tools
>or processes. If switching to "packaging" prevents me from doing this then it
>will inhibit me using "packaging".
It definitely shouldn't prevent this. I personally do the same thing, and it
seems the least bad way of doing it. I think the clear version string
assigned to __version__ is the best recommendation (though not the only one)
that the PEP makes.
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110412/430fc949/attachment.pgp>
More information about the Python-Dev
mailing list