[Python-checkins] commit of r41630 - in sandbox/trunk/setuptools: pkg_resources.py pkg_resources.txt setuptools/tests/test_resources.py

phillip.eby python-checkins at python.org
Tue Dec 6 18:41:41 CET 2005


Author: phillip.eby
Date: Tue Dec  6 18:41:36 2005
New Revision: 41630

Modified:
   sandbox/trunk/setuptools/pkg_resources.py
   sandbox/trunk/setuptools/pkg_resources.txt
   sandbox/trunk/setuptools/setuptools/tests/test_resources.py
Log:
Changed ``parse_version()`` to remove dashes before pre-release tags, so
that ``0.2-rc1`` is considered an *older* version than ``0.2``, and is equal
to ``0.2rc1``.  The idea that a dash *always* meant a post-release version 
was highly non-intuitive to setuptools users and Python developers, who 
seem to want to use ``-rc`` version numbers a lot.



Modified: sandbox/trunk/setuptools/pkg_resources.py
==============================================================================
--- sandbox/trunk/setuptools/pkg_resources.py	(original)
+++ sandbox/trunk/setuptools/pkg_resources.py	Tue Dec  6 18:41:36 2005
@@ -1589,14 +1589,14 @@
     parts = []
     for part in _parse_version_parts(s.lower()):
         if part.startswith('*'):
+            if part<'*final':   # remove '-' before a prerelease tag
+                while parts and parts[-1]=='*final-': parts.pop()
             # remove trailing zeros from each series of numeric parts
             while parts and parts[-1]=='00000000':
                 parts.pop()
         parts.append(part)
     return tuple(parts)
 
-
-
 class EntryPoint(object):
     """Object representing an advertised importable object"""
 

Modified: sandbox/trunk/setuptools/pkg_resources.txt
==============================================================================
--- sandbox/trunk/setuptools/pkg_resources.txt	(original)
+++ sandbox/trunk/setuptools/pkg_resources.txt	Tue Dec  6 18:41:36 2005
@@ -1371,7 +1371,11 @@
 
     Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that
     come before "final" alphabetically) are assumed to be pre-release versions,
-    so that the version "2.4" is considered newer than "2.4a1".
+    so that the version "2.4" is considered newer than "2.4a1".  Any "-"
+    characters preceding a pre-release indicator are removed.  (In versions of
+    setuptools prior to 0.6a9, "-" characters were not removed, leading to the
+    unintuitive result that "0.2-rc1" was considered a newer version than
+    "0.2".)
 
     Finally, to handle miscellaneous cases, the strings "pre", "preview", and
     "rc" are treated as if they were "c", i.e. as though they were release
@@ -1518,6 +1522,12 @@
    system-installed egg, without needing to use ``.egg`` directories, zipfiles,
    or ``.pth`` manipulation.
 
+ * Changed ``parse_version()`` to remove dashes before pre-release tags, so
+   that ``0.2-rc1`` is considered an *older* version than ``0.2``, and is equal
+   to ``0.2rc1``.  The idea that a dash *always* meant a post-release version
+   was highly non-intuitive to setuptools users and Python developers, who
+   seem to want to use ``-rc`` version numbers a lot.
+
 0.6a8
  * Fixed a problem with ``WorkingSet.resolve()`` that prevented version
    conflicts from being detected at runtime.

Modified: sandbox/trunk/setuptools/setuptools/tests/test_resources.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/tests/test_resources.py	(original)
+++ sandbox/trunk/setuptools/setuptools/tests/test_resources.py	Tue Dec  6 18:41:36 2005
@@ -434,19 +434,19 @@
         self.assertRaises(ValueError,Requirement.parse,"X==1\nY==2")
         self.assertRaises(ValueError,Requirement.parse,"#")
 
-
     def testVersionEquality(self):
         def c(s1,s2):
             p1, p2 = parse_version(s1),parse_version(s2)
             self.assertEqual(p1,p2, (s1,s2,p1,p2))
 
+        c('1.2-rc1', '1.2rc1')
         c('0.4', '0.4.0')
         c('0.4.0.0', '0.4.0')
         c('0.4.0-0', '0.4-0')
         c('0pl1', '0.0pl1')
         c('0pre1', '0.0c1')
         c('0.0.0preview1', '0c1')
-        c('0.0c1', '0rc1')
+        c('0.0c1', '0-rc1')
         c('1.2a1', '1.2.a.1'); c('1.2...a', '1.2a')
 
     def testVersionOrdering(self):
@@ -470,6 +470,7 @@
         c('0.4', '4.0')
         c('0.0.4', '0.4.0')
         c('0pl1', '0.4pl1')
+        c('2.1.0-rc1','2.1.0')
 
         torture ="""
         0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1
@@ -489,4 +490,3 @@
 
 
 
-


More information about the Python-checkins mailing list