diff options
author | tarek <none@none> | 2009-07-20 09:24:00 +0200 |
---|---|---|
committer | tarek <none@none> | 2009-07-20 09:24:00 +0200 |
commit | d3ba8f0b0453488d8dea19c58de696b9edb7dc08 (patch) | |
tree | f7d5949cc7413992ba448507ae3a39116740e39d | |
parent | 45ae6fb6610ca3faed32b0267d2cbdd1f8578e59 (diff) | |
download | external_python_setuptools-d3ba8f0b0453488d8dea19c58de696b9edb7dc08.tar.gz external_python_setuptools-d3ba8f0b0453488d8dea19c58de696b9edb7dc08.tar.bz2 external_python_setuptools-d3ba8f0b0453488d8dea19c58de696b9edb7dc08.zip |
making ez_setup removing an existing setuptools distribution out of the way
--HG--
branch : distribute
extra : rebase_source : a97ad8f22e698747b81a097215b8ebffdf7edae6
-rwxr-xr-x | ez_setup.py | 30 | ||||
-rw-r--r-- | setuptools/__init__.py | 9 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 3 |
3 files changed, 39 insertions, 3 deletions
diff --git a/ez_setup.py b/ez_setup.py index e3fe481c..8fc5d68f 100755 --- a/ez_setup.py +++ b/ez_setup.py @@ -14,7 +14,7 @@ the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import sys -import sys, os +import os try: from hashlib import md5 except ImportError: @@ -133,6 +133,34 @@ def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" try: import setuptools + # we need to check if the installed setuptools + # is from Distribute or from setuptools + if not hasattr(setuptools, '_distribute'): + # we have a setuptools distribution, we need to get out + # of our way. This is done by removing all references + # of setuptools egg from .pth files. + + # removing setuptools distribution from easy_install.pth + # using the --multi-version option seems like the safest + # way to do this. + from setuptools.command.easy_install import main + main(['-q', '-m', 'setuptools']) + + # now removing setuptool.pth manually so installing + # 'distribute' will re-create it. Notice that a -U call + # will have the same effect. + from setuptools.command.easy_install import easy_install + from setuptools.dist import Distribution + dist = Distribution() + cmd = easy_install(dist) + cmd.args = ['setuptools'] + cmd.ensure_finalized() + pth_file = os.path.join(cmd.install_dir, 'setuptools.pth') + if os.path.exists(pth_file): + os.remove(pth_file) + + # now we are ready to install distribute + raise ImportError except ImportError: egg = None try: diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 54dd8158..f911ef8f 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -13,6 +13,15 @@ __all__ = [ 'find_packages' ] +# This marker is used to simplify the process that checks is the +# setuptools package was installed by the Setuptools project +# or by the Distribute project, in case Setuptools creates +# a distribution with the same version. +# +# The ez_setup script for instance, will check if this +# attribute is present to decide wether to reinstall the package +_distribute = True + bootstrap_install_from = None def find_packages(where='.', exclude=()): diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 2289b1d5..228a9a69 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -969,8 +969,7 @@ See the setuptools documentation for the "develop" command for more info. if not self.dry_run: self.pth_file.save() - - if dist.key=='setuptools': + if dist.key=='distribute': # Ensure that setuptools itself never becomes unavailable! # XXX should this check for latest version? filename = os.path.join(self.install_dir,'setuptools.pth') |