summaryrefslogtreecommitdiff
path: root/pkg_resources.py
diff options
context:
space:
mode:
authorReinout van Rees <reinout@vanrees.org>2009-10-14 14:39:55 +0200
committerReinout van Rees <reinout@vanrees.org>2009-10-14 14:39:55 +0200
commitdd2b4ffb2f582bf8270c0ceed490bf035a9e553b (patch)
treed36166d4eaf3131aa1d204c81ad6335e535a038f /pkg_resources.py
parentf0daab74fc160d92ff534af1097c892140f6a46b (diff)
downloadpython-setuptools-git-dd2b4ffb2f582bf8270c0ceed490bf035a9e553b.tar.gz
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
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 1d5d8643..510be536 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -504,8 +504,7 @@ class WorkingSet(object):
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:
@@ -2501,8 +2500,7 @@ class Requirement:
# 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]
@@ -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):
"""Get an mro for a type or classic class"""
if not isinstance(cls,type):