Commit dd2b4ffb authored by Reinout van Rees's avatar Reinout van Rees

Distribute no longer shadows setuptools if we require a 0.7-series

  setuptools.
Added _override_setuptools() checker method and calling it in two places that checks whether we request a setuptools from the 0.7 series. Including test.

--HG--
branch : distribute
extra : rebase_source : 51c89e02721de2e31c9392d1ead76ac1e828810c
parent f0daab74
...@@ -6,6 +6,9 @@ CHANGES ...@@ -6,6 +6,9 @@ CHANGES
0.6.5 0.6.5
----- -----
* Distribute no longer shadows setuptools if we require a 0.7-series
setuptools.
* When run from within buildout, no attempt is made to modify an existing * When run from within buildout, no attempt is made to modify an existing
setuptools egg, whether in a shared egg directory or a system setuptools. setuptools egg, whether in a shared egg directory or a system setuptools.
......
...@@ -504,8 +504,7 @@ class WorkingSet(object): ...@@ -504,8 +504,7 @@ class WorkingSet(object):
while requirements: while requirements:
req = requirements.pop(0) # process dependencies breadth-first req = requirements.pop(0) # process dependencies breadth-first
if req.project_name == 'setuptools': if _override_setuptools(req):
# TODO: only return distribute if setuptools < 0.7
req = Requirement.parse('distribute') req = Requirement.parse('distribute')
if req in processed: if req in processed:
...@@ -2501,8 +2500,7 @@ class Requirement: ...@@ -2501,8 +2500,7 @@ class Requirement:
# if asked for setuptools distribution # if asked for setuptools distribution
# and if distribute is installed, we want to give # and if distribute is installed, we want to give
# distribute instead # distribute instead
if founded_req.project_name == 'setuptools': if _override_setuptools(founded_req):
# TODO: only return distribute if setuptools < 0.7
distribute = list(parse_requirements('distribute')) distribute = list(parse_requirements('distribute'))
if len(distribute) == 1: if len(distribute) == 1:
return distribute[0] return distribute[0]
...@@ -2526,6 +2524,26 @@ state_machine = { ...@@ -2526,6 +2524,26 @@ state_machine = {
} }
def _override_setuptools(req):
"""Return True when distribute wants to override a setuptools dependency.
We want to override when the requirement is setuptools and the version is
a variant of 0.6.
"""
if req.project_name == 'setuptools':
if not len(req.specs):
# Just setuptools: ok
return True
for comparator, version in req.specs:
if comparator in ['==', '>=', '>']:
if '0.7' in version:
# We want some setuptools not from the 0.6 series.
return False
return True
return False
def _get_mro(cls): def _get_mro(cls):
"""Get an mro for a type or classic class""" """Get an mro for a type or classic class"""
if not isinstance(cls,type): if not isinstance(cls,type):
......
...@@ -354,8 +354,28 @@ class RequirementsTests(TestCase): ...@@ -354,8 +354,28 @@ class RequirementsTests(TestCase):
self.failUnless(d("foo-0.3a3.egg") in r2) self.failUnless(d("foo-0.3a3.egg") in r2)
self.failUnless(d("foo-0.3a5.egg") in r2) self.failUnless(d("foo-0.3a5.egg") in r2)
def testDistributeSetuptoolsOverride(self):
# Plain setuptools or distribute mean we return distribute.
self.assertEqual(
Requirement.parse('setuptools').project_name, 'distribute')
self.assertEqual(
Requirement.parse('distribute').project_name, 'distribute')
# setuptools lower than 0.7 means distribute
self.assertEqual(
Requirement.parse('setuptools==0.6c9').project_name, 'distribute')
self.assertEqual(
Requirement.parse('setuptools==0.6c10').project_name, 'distribute')
self.assertEqual(
Requirement.parse('setuptools>=0.6').project_name, 'distribute')
self.assertEqual(
Requirement.parse('setuptools < 0.7').project_name, 'distribute')
# setuptools 0.7 and higher means setuptools.
self.assertEqual(
Requirement.parse('setuptools == 0.7').project_name, 'setuptools')
self.assertEqual(
Requirement.parse('setuptools == 0.7a1').project_name, 'setuptools')
self.assertEqual(
Requirement.parse('setuptools >= 0.7').project_name, 'setuptools')
......
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