| 206 | |
| 207 | |
| 208 | def _no_sandbox(function): |
| 209 | def __no_sandbox(*args, **kw): |
| 210 | try: |
| 211 | from setuptools.sandbox import DirectorySandbox |
| 212 | if not hasattr(DirectorySandbox, '_old'): |
| 213 | def violation(*args): |
| 214 | pass |
| 215 | DirectorySandbox._old = DirectorySandbox._violation |
| 216 | DirectorySandbox._violation = violation |
| 217 | patched = True |
| 218 | else: |
| 219 | patched = False |
| 220 | except ImportError: |
| 221 | patched = False |
| 222 | |
| 223 | try: |
| 224 | return function(*args, **kw) |
| 225 | finally: |
| 226 | if patched: |
| 227 | DirectorySandbox._violation = DirectorySandbox._old |
| 228 | del DirectorySandbox._old |
| 229 | |
| 230 | return __no_sandbox |
| 231 | |
| 232 | |
| 233 | def _patch_file(path, content): |