diff options
author | Marcus Smith <qwcode@gmail.com> | 2013-06-12 23:10:01 -0700 |
---|---|---|
committer | Marcus Smith <qwcode@gmail.com> | 2013-06-19 17:08:32 -0700 |
commit | 1a182cb8192666280c4b8098feee64c317ee665c (patch) | |
tree | 11cb225b413be29aeb2356614a397c6bc5912e78 /pip/req.py | |
parent | 81639adbdfe973bcb12ef9013389dfad70a80ac2 (diff) | |
download | pip-1a182cb8192666280c4b8098feee64c317ee665c.tar.gz |
force setuptools>=0.7.2 to uninstall distribute
Diffstat (limited to 'pip/req.py')
-rw-r--r-- | pip/req.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/pip/req.py b/pip/req.py index e4780722b..4c4a66052 100644 --- a/pip/req.py +++ b/pip/req.py @@ -735,7 +735,15 @@ exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec')) if self.req is None: return False try: - self.satisfied_by = pkg_resources.get_distribution(self.req) + # if we've already set distribute as a conflict to setuptools + # then this check has already run before. we don't want it to + # run again, and return False, since it would block the uninstall + if (self.req.project_name == 'setuptools' + and self.conflicts_with + and self.conflicts_with.project_name == 'distribute'): + return True + else: + self.satisfied_by = pkg_resources.get_distribution(self.req) except pkg_resources.DistributionNotFound: return False except pkg_resources.VersionConflict: @@ -1254,9 +1262,9 @@ class RequirementSet(object): # setuptools dependency is handled first, which will provide an # importable setuptools package # TODO: take this out later + distribute_req = pkg_resources.Requirement.parse("distribute>=0.7") for req in to_install: - version = pkg_resources.parse_version('0.7') - if req.name == 'distribute' and pkg_resources.parse_version(req.installed_version) >= version: + if req.name == 'distribute' and req.installed_version in distribute_req: to_install.remove(req) to_install.append(req) @@ -1265,6 +1273,20 @@ class RequirementSet(object): logger.indent += 2 try: for requirement in to_install: + + # when installing setuptools>=0.7.2 in py2, we need to force setuptools + # to uninstall distribute. In py3, which is always using distribute, this + # conversion is already happening in distribute's pkg_resources. + # TODO: remove this later + setuptools_req = pkg_resources.Requirement.parse("setuptools>=0.7.2") + if requirement.name == 'setuptools' and requirement.installed_version in setuptools_req: + try: + existing_distribute = pkg_resources.get_distribution("distribute") + requirement.conflicts_with = existing_distribute + except: + # distribute wasn't installed + pass + if requirement.conflicts_with: logger.notify('Found existing installation: %s' % requirement.conflicts_with) |