Commits

Barry Warsaw committed ed1008f

Updates based on python-dev feedback.

* Remove the __version_info__ tuple discussion. Because of the sorting order
for the non-numeric sections, this can't really work.
* Remove the regexp code sample; it was distracting and ultimately isn't the
core of this PEP.

Comments (0)

Files changed (1)

 of an ``__version__`` module attribute by independent module
 developers dates back to 1995.
 
-Another example of version information is the sqlite3 [5]_ library
+Another example of version information is the sqlite3 [5]_ module
 with its ``sqlite_version_info``, ``version``, and ``version_info``
 attributes.  It may not be immediately obvious which attribute
 contains a version number for the module, and which contains a version
    supplied revision numbers, or any other semantically different
    version numbers (e.g. underlying library version number).
 
-#. Wherever a ``__version__`` attribute exists, a module MAY also
-   include a ``__version_info__`` attribute, containing a tuple
-   representation of the module version number, for easy comparisons.
-
-#. ``__version_info__`` SHOULD be of the format returned by PEP 386's
-   ``parse_version()`` function.
-
 #. The ``version`` attribute in a classic distutils ``setup.py``
    file, or the PEP 345 [7]_ ``Version`` metadata field SHOULD be
    derived from the ``__version__`` field, or vice versa.
 number once, and have all the other uses derive from this single
 definition.
 
-While there are any number of ways this could be done, this section
-describes one possible approach, for each scenario.
+This could be done in any number of ways, a few of which are outlined
+below.  These are included for illustrative purposes only and are not
+intended to be definitive, complete, or all-encompassing.  Other
+approaches are possible, and some included below may have limitations
+that prevent their use in some situations.
 
 Let's say Elle adds this attribute to her module file ``elle.py``::
 
 the ``elle`` module has been converted).
 
 In that case, it's not much more difficult to write a little code to
-parse the ``__version__`` from the file rather than importing it::
+parse the ``__version__`` from the file rather than importing it.
+Without providing too much detail, it's likely that modules such as
+``distutils2`` will provide a way to parse version strings from files.
+E.g.::
 
-    import re
-    DEFAULT_VERSION_RE = re.compile(r'(?P<version>\d+\.\d(?:\.\d+)?)')
-
-    def get_version(filename, pattern=None):
-        if pattern is None:
-            cre = DEFAULT_VERSION_RE
-        else:
-            cre = re.compile(pattern)
-        with open(filename) as fp:
-            for line in fp:
-                if line.startswith('__version__'):
-                    mo = cre.search(line)
-                    assert mo, 'No valid __version__ string found'
-                    return mo.group('version')
-        raise AssertionError('No __version__ assignment found')
-
+    from distutils2 import get_version
     setup(name='elle', version=get_version('elle.py'))