aboutsummaryrefslogtreecommitdiffstats
path: root/distribute_setup.py
diff options
context:
space:
mode:
authortarek <none@none>2009-12-11 01:10:45 +0100
committertarek <none@none>2009-12-11 01:10:45 +0100
commitfa3779fa3ec3d90437043321477c34d496dde38a (patch)
tree351f7d4b5c1e728ae321483b1e995fe09eb4b29b /distribute_setup.py
parentce6ac29bfa586e8646853b3f58e0c8c8e6891629 (diff)
downloadexternal_python_setuptools-fa3779fa3ec3d90437043321477c34d496dde38a.tar.gz
external_python_setuptools-fa3779fa3ec3d90437043321477c34d496dde38a.tar.bz2
external_python_setuptools-fa3779fa3ec3d90437043321477c34d496dde38a.zip
avoid sandbox violations on installation fixes #100
--HG-- branch : distribute extra : rebase_source : 30a4c67f59ad25edf59133af2986191265811635
Diffstat (limited to 'distribute_setup.py')
-rw-r--r--distribute_setup.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/distribute_setup.py b/distribute_setup.py
index 7fd3b4d8..fac916e6 100644
--- a/distribute_setup.py
+++ b/distribute_setup.py
@@ -224,22 +224,34 @@ def _patch_file(path, content):
def _same_content(path, content):
return open(path).read() == content
+def _no_sandbox(function):
+ def __no_sandbox(*args, **kw):
+ try:
+ from setuptools.sandbox import DirectorySandbox
+ def violation(*args):
+ pass
+ DirectorySandbox._old = DirectorySandbox._violation
+ DirectorySandbox._violation = violation
+ patched = True
+ except ImportError:
+ patched = False
+ try:
+ return function(*args, **kw)
+ finally:
+ if patched:
+ DirectorySandbox._violation = DirectorySandbox._old
+ del DirectorySandbox._old
+
+ return __no_sandbox
+
+@_no_sandbox
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
-
def _remove_flat_installation(placeholder):
if not os.path.isdir(placeholder):
log.warn('Unkown installation at %s', placeholder)
@@ -279,6 +291,7 @@ def _after_install(dist):
placeholder = dist.get_command_obj('install').install_purelib
_create_fake_setuptools_pkg_info(placeholder)
+@_no_sandbox
def _create_fake_setuptools_pkg_info(placeholder):
if not placeholder or not os.path.exists(placeholder):
log.warn('Could not find the install location')
@@ -290,12 +303,14 @@ def _create_fake_setuptools_pkg_info(placeholder):
if os.path.exists(pkg_info):
log.warn('%s already exists', pkg_info)
return
+
log.warn('Creating %s', pkg_info)
f = open(pkg_info, 'w')
try:
f.write(SETUPTOOLS_PKG_INFO)
finally:
f.close()
+
pth_file = os.path.join(placeholder, 'setuptools.pth')
log.warn('Creating %s', pth_file)
f = open(pth_file, 'w')
@@ -304,7 +319,6 @@ def _create_fake_setuptools_pkg_info(placeholder):
finally:
f.close()
-
def _patch_egg_dir(path):
# let's check if it's already patched
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')