[Python-Dev] Module version variable

Barry Warsaw barry at python.org
Wed Mar 16 17:53:34 CET 2011


On Mar 16, 2011, at 12:39 PM, Alexander Belopolsky wrote:

>I was editing the turtle module (for issue11571, if you are
>interested) when I noticed that it has the following line:
>
>_ver = "turtle 1.1b- - for Python 3.1   -  4. 5. 2009"
>
>This is obviously out of date and this variable is not used anywhere
>in the module.  I would simply delete it, but I wonder if there is any
>recommended mechanism for maintaining module versions.
>
>Some modules define __version__ which has a special meaning at least
>for pydoc and possibly some third party tools.  In many cases it is
>never updated and its format and meaning varies from module to module.
> (For example, decimal module stores the version of the spec rather
>than the version of the module in __version__.)
>
>In several instances, __version__ is set to "$Revision$" in an
>apparent attempt to leverage VCS to keep it up to date, but this does
>not seem to work after hg transition.  For example,
>
>$  ./python.exe -m pydoc pydoc
>..
>VERSION
>    $Revision$
>
>The other affected modules are pickle and tarfile.
>
>Do you have an advise on how these issues should be handled?

MvL and I had a discussion about this at the sprint.  I am planning on writing
an informational PEP that proposes __version__ as a standard convention.  I'd
like to be able to do:

    >>> import foo
    >>> foo.__version__

It won't be mandatory (thus the informational PEP), but it should be
formalized as the preferred way to introspect a module for its version
number.  I think there should be ways to spell this easily if the information
is provided to packaging/distutils2 so that it can basically always be kept up
to date without violating DRY.

-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/20110316/e0f9de9a/attachment.pgp>


More information about the Python-Dev mailing list