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 /ez_setup.py | |
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
Diffstat (limited to 'ez_setup.py')
-rwxr-xr-x | ez_setup.py | 30 |
1 files changed, 29 insertions, 1 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: |