Reinout van Rees avatar Reinout van Rees committed 32f2b4e

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.

Comments (0)

Files changed (3)

 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
   setuptools egg, whether in a shared egg directory or a system setuptools.
 
 
         while requirements:
             req = requirements.pop(0)   # process dependencies breadth-first
-            if req.project_name == 'setuptools':
-                # TODO: only return distribute if setuptools < 0.7
+            if _override_setuptools(req):
                 req = Requirement.parse('distribute')
 
             if req in processed:
                 # if asked for setuptools distribution
                 # and if distribute is installed, we want to give
                 # distribute instead
-                if founded_req.project_name == 'setuptools':
-                    # TODO: only return distribute if setuptools < 0.7
+                if _override_setuptools(founded_req):
                     distribute = list(parse_requirements('distribute'))
                     if len(distribute) == 1:
                         return distribute[0]
 }
 
 
+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):
     """Get an mro for a type or classic class"""
     if not isinstance(cls,type):

setuptools/tests/test_resources.py

         self.failUnless(d("foo-0.3a3.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')
 
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.