summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-02-16 02:13:45 -0500
committerJason R. Coombs <jaraco@jaraco.com>2013-02-16 02:13:45 -0500
commitb5cd47fbd96ae900dd835b68484084ab1219f260 (patch)
tree1fac3914b18177434274b291e72c61a6b0595ba3
parent5f738c54a3de45e1f44321eb8e27cfe10ce97e90 (diff)
downloadpython-setuptools-git-b5cd47fbd96ae900dd835b68484084ab1219f260.tar.gz
Backed out changeset: d0a8d1a83053
In the discussion in #278, it became clear that the deviance in behavior from setuptools is problemmatic. For compatibility, defer to the setuptools version scheme as specifically intended. --HG-- branch : distribute extra : rebase_source : 1d5cc8c216f974b247e2dc84d8d40c868d6d3639
-rw-r--r--pkg_resources.py4
-rw-r--r--setuptools/tests/test_resources.py20
2 files changed, 6 insertions, 18 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 49aab675..69601480 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -1936,7 +1936,7 @@ replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}.get
def _parse_version_parts(s):
for part in component_re.split(s):
part = replace(part,part)
- if part in ['', '.']:
+ if not part or part=='.':
continue
if part[:1] in '0123456789':
yield part.zfill(8) # pad for numeric comparison
@@ -1979,6 +1979,8 @@ def parse_version(s):
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()
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 0bc1a095..292b78d1 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -477,13 +477,14 @@ class ParseTests(TestCase):
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):
@@ -492,14 +493,11 @@ class ParseTests(TestCase):
self.assertTrue(p1<p2, (s1,s2,p1,p2))
c('2.1','2.1.1')
- c('2.1.0','2.10')
c('2a1','2b0')
- c('2b1','2c0')
c('2a1','2.1')
c('2.3a1', '2.3')
c('2.1-1', '2.1-2')
c('2.1-1', '2.1.1')
- c('2.1', '2.1.1-1')
c('2.1', '2.1pl4')
c('2.1a0-20040501', '2.1')
c('1.1', '02.1')
@@ -510,20 +508,8 @@ class ParseTests(TestCase):
c('0.4', '4.0')
c('0.0.4', '0.4.0')
c('0pl1', '0.4pl1')
+ c('2.1.0-rc1','2.1.0')
c('2.1dev','2.1a0')
- c('2.1.0rc1','2.1.0')
- c('2.1.0','2.1.0-rc0')
- c('2.1.0','2.1.0-a')
- c('2.1.0','2.1.0-alpha')
- c('2.1.0','2.1.0-foo')
- c('1.0','1.0-1')
- c('1.0-1','1.0.1')
- c('1.0a','1.0b')
- c('1.0dev','1.0rc1')
- c('1.0pre','1.0')
- c('1.0pre','1.0')
- c('1.0a','1.0-a')
- c('1.0rc1','1.0-rc1')
torture ="""
0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1