diff options
author | tarek <none@none> | 2009-09-08 13:12:44 +0200 |
---|---|---|
committer | tarek <none@none> | 2009-09-08 13:12:44 +0200 |
commit | 89e9dfcd6d1d97f8439844a80e66c7c5a9dfaae3 (patch) | |
tree | f7a91a864a41080a94603b33062b8308a1bb60a2 | |
parent | ae8f6226eacfce9c5519f562c750b9db7aa98bdf (diff) | |
download | external_python_setuptools-89e9dfcd6d1d97f8439844a80e66c7c5a9dfaae3.tar.gz external_python_setuptools-89e9dfcd6d1d97f8439844a80e66c7c5a9dfaae3.tar.bz2 external_python_setuptools-89e9dfcd6d1d97f8439844a80e66c7c5a9dfaae3.zip |
easy_install Distribute now calls the setuptools fake machinery fixes #40
--HG--
branch : distribute
extra : rebase_source : abcd8e82c2de583da133b160ba9e31248d5ae264
-rw-r--r-- | distribute_setup.py | 16 | ||||
-rwxr-xr-x | setup.py | 12 |
2 files changed, 24 insertions, 4 deletions
diff --git a/distribute_setup.py b/distribute_setup.py index c2ef008f..923a1e98 100644 --- a/distribute_setup.py +++ b/distribute_setup.py @@ -13,6 +13,7 @@ the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ +from site import USER_SITE import sys import os import shutil @@ -162,7 +163,7 @@ def _patch_file(path, content): log.warn('Already patched.') return False log.warn('Patching...') - os.rename(path, path +'.OLD.%s' % time.time()) + _rename_path(path) f = open(path, 'w') try: f.write(content) @@ -176,6 +177,14 @@ def _same_content(path, content): def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s' % (path, new_name)) + try: + from setuptools.sandbox import DirectorySandbox + def _violation(*args): + pass + DirectorySandbox._violation = _violation + except ImportError: + pass + os.rename(path, new_name) return new_name @@ -260,8 +269,9 @@ def before_install(): fake_setuptools() def _under_prefix(location): + if 'install' not in sys.argv: + return True args = sys.argv[sys.argv.index('install')+1:] - for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -271,6 +281,8 @@ def _under_prefix(location): if len(args) > index: top_dir = args[index+1] return location.startswith(top_dir) + elif option == '--user': + return location.startswith(USER_SITE) return True def fake_setuptools(): @@ -16,7 +16,14 @@ scripts = [] # if we are installing Distribute using "python setup.py install" # we need to get setuptools out of the way -if 'install' in sys.argv[1:]: +def _being_installed(): + # easy_install marker + if (len(sys.argv) == 5 and sys.argv[2] == 'bdist_egg' and + sys.argv[3] == '--dist-dir'): + return True + return 'install' in sys.argv[1:] + +if _being_installed(): from distribute_setup import before_install before_install() @@ -100,7 +107,8 @@ dist = setup( Topic :: Utilities""".splitlines() if f.strip()], scripts = scripts, ) -if 'install' in sys.argv[1:]: + +if _being_installed(): from distribute_setup import after_install after_install(dist) |