Commit 28db1979 authored by PJ Eby's avatar PJ Eby

Fix handling of -/_ so that they are canonicalized to '-' when doing name

or version comparisons, but rendered as '_' in egg filenames.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041002
parent 7311c34a
......@@ -623,6 +623,7 @@ class Distribution(object):
name,version,py_version,platform = match.group(
'name','ver','pyver','plat'
)
name = name.replace('_','-')
if version and '_' in version:
version = version.replace('_','-')
return cls(
......@@ -653,7 +654,6 @@ class Distribution(object):
parsed_version = property(parsed_version)
def parse_requirements(strs):
"""Yield ``Requirement`` objects for each specification in `strs`
......@@ -681,7 +681,8 @@ def parse_requirements(strs):
match = VERSION(line,p)
if not match:
raise ValueError("Expected version spec in",line,"at",line[p:])
specs.append(match.group(1,2))
op,val = match.group(1,2)
specs.append((op,val.replace('_','-')))
p = match.end()
match = COMMA(line,p)
if match:
......@@ -689,7 +690,7 @@ def parse_requirements(strs):
elif not LINE_END(line,p):
raise ValueError("Expected ',' or EOL in",line,"at",line[p:])
yield distname, specs
yield distname.replace('_','-'), specs
......
......@@ -53,8 +53,8 @@ class ParseTests(TestCase):
def testSimple(self):
self.assertEqual(
list(parse_requirements('Twis-Ted>=1.2')),
[('Twis_Ted',[('>=','1.2')])]
list(parse_requirements('Twis-Ted>=1.2-1')),
[('Twis-Ted',[('>=','1.2-1')])]
)
self.assertEqual(
list(parse_requirements('Twisted >=1.2, \ # more\n<2.0')),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment