[Python-Dev] PEP 396, Module Version Numbers
John Arbash Meinel
john at arbash-meinel.com
Wed Apr 6 11:04:08 CEST 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
> #. ``__version_info__`` SHOULD be of the format returned by PEP 386's
> ``parse_version()`` function.
The only reference to parse_version in PEP 386 I could find was the
setuptools implementation which is pretty odd:
>
> In other words, parse_version will return a tuple for each version string, that is compatible with StrictVersion but also accept arbitrary version and deal with them so they can be compared:
>
>>>> from pkg_resources import parse_version as V
>>>> V('1.2')
> ('00000001', '00000002', '*final')
>>>> V('1.2b2')
> ('00000001', '00000002', '*b', '00000002', '*final')
>>>> V('FunkyVersion')
> ('*funkyversion', '*final')
bzrlib has certainly used 'version_info' as a tuple indication such as:
version_info = (2, 4, 0, 'dev', 2)
and
version_info = (2, 4, 0, 'beta', 1)
and
version_info = (2, 3, 1, 'final', 0)
etc.
This is mapping what we could sort out from Python's "sys.version_info".
The *really* nice bit is that you can do:
if sys.version_info >= (2, 6):
# do stuff for python 2.6(.0) and beyond
Doing that as:
if sys.version_info >= ('000000002', '000000006'):
is pretty ugly.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk2cLIcACgkQJdeBCYSNAAPT9wCg01L2s0DcqXE+zBAVPB7/Ts0W
HwgAnRRrzR1yiQCSeFGh9jZzuXYrHwPz
=0l4b
-----END PGP SIGNATURE-----
More information about the Python-Dev
mailing list