aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources.py
diff options
context:
space:
mode:
authortarek <none@none>2009-10-18 14:32:54 +0200
committertarek <none@none>2009-10-18 14:32:54 +0200
commit33e3ec5eadb59ece949d4cad1231ff23780e4c02 (patch)
treec6e5d835fbce01a2d1023fbe7ca0a40c605a9670 /pkg_resources.py
parent6529a376d21b45fbc8f8ca33bd797c21f4589f35 (diff)
downloadexternal_python_setuptools-33e3ec5eadb59ece949d4cad1231ff23780e4c02.tar.gz
external_python_setuptools-33e3ec5eadb59ece949d4cad1231ff23780e4c02.tar.bz2
external_python_setuptools-33e3ec5eadb59ece949d4cad1231ff23780e4c02.zip
make sure pkg_resources can be imported in GAE - refs #73
--HG-- branch : distribute extra : rebase_source : fa1f9aca1bb3b231b7e709de9fc78973cce053ed
Diffstat (limited to 'pkg_resources.py')
-rw-r--r--pkg_resources.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg_resources.py b/pkg_resources.py
index 49c26620..31d83554 100644
--- a/pkg_resources.py
+++ b/pkg_resources.py
@@ -21,7 +21,14 @@ except NameError:
from sets import ImmutableSet as frozenset
# capture these to bypass sandboxing
-from os import utime, rename, unlink, mkdir
+from os import utime
+try:
+ from os import mkdir, rename, unlink
+ WRITE_SUPPORT = True
+except ImportError:
+ # no write support, probably under GAE
+ WRITE_SUPPORT = False
+
from os import open as os_open
from os.path import isdir, split
@@ -36,6 +43,8 @@ _distribute = True
def _bypass_ensure_directory(name, mode=0777):
# Sandbox-bypassing version of ensure_directory()
+ if not WRITE_SUPPORT:
+ raise IOError('"os.mkdir" not supported on this platform.')
dirname, filename = split(name)
if dirname and filename and not isdir(dirname):
_bypass_ensure_directory(dirname)
@@ -1332,6 +1341,10 @@ class ZipProvider(EggProvider):
timestamp = time.mktime(date_time)
try:
+ if not WRITE_SUPPORT:
+ raise IOError('"os.rename" and "os.unlink" are not supported '
+ 'on this platform')
+
real_path = manager.get_cache_path(
self.egg_name, self._parts(zip_path)
)