aboutsummaryrefslogtreecommitdiffstats
path: root/distribute_setup.py
diff options
context:
space:
mode:
authortarek <none@none>2009-08-25 19:44:53 +0200
committertarek <none@none>2009-08-25 19:44:53 +0200
commit81b3818500aef5efe1151c60a4ffb8d6ad28331e (patch)
treed4f7384e9f45abb008570d74a5747ae71f9b917e /distribute_setup.py
parenta95877cd71522f5a2f5af90e2e2bfaa5d33ab3e2 (diff)
downloadexternal_python_setuptools-81b3818500aef5efe1151c60a4ffb8d6ad28331e.tar.gz
external_python_setuptools-81b3818500aef5efe1151c60a4ffb8d6ad28331e.tar.bz2
external_python_setuptools-81b3818500aef5efe1151c60a4ffb8d6ad28331e.zip
not removing a setuptools instance that is not part of the same root/prefix
--HG-- branch : distribute extra : rebase_source : 2193299f01f96c29fb447c024b2051c91ae6bb7b
Diffstat (limited to 'distribute_setup.py')
-rw-r--r--distribute_setup.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/distribute_setup.py b/distribute_setup.py
index e50956fd..c2ef008f 100644
--- a/distribute_setup.py
+++ b/distribute_setup.py
@@ -259,6 +259,20 @@ def before_install():
log.warn('Before install bootstrap.')
fake_setuptools()
+def _under_prefix(location):
+ args = sys.argv[sys.argv.index('install')+1:]
+
+ for index, arg in enumerate(args):
+ for option in ('--root', '--prefix'):
+ if arg.startswith('%s=' % option):
+ top_dir = arg.split('root=')[-1]
+ return location.startswith(top_dir)
+ elif arg == option:
+ if len(args) > index:
+ top_dir = args[index+1]
+ return location.startswith(top_dir)
+ return True
+
def fake_setuptools():
log.warn('Scanning installed packages')
try:
@@ -276,6 +290,13 @@ def fake_setuptools():
setuptools_location = setuptools_dist.location
log.warn('Setuptools installation detected at %s' % setuptools_location)
+ # if --root or --preix was provided, and if
+ # setuptools is not located in them, we don't patch it
+ if not _under_prefix(setuptools_location):
+ log.warn('Not patching, --root or --prefix is installing Distribute'
+ ' in another location')
+ return
+
# let's see if its an egg
if not setuptools_location.endswith('.egg'):
log.warn('Non-egg installation')