Commit 33e3ec5e authored by tarek's avatar tarek

make sure pkg_resources can be imported in GAE - refs #73

--HG--
branch : distribute
extra : rebase_source : fa1f9aca1bb3b231b7e709de9fc78973cce053ed
parent 6529a376
...@@ -21,7 +21,14 @@ except NameError: ...@@ -21,7 +21,14 @@ except NameError:
from sets import ImmutableSet as frozenset from sets import ImmutableSet as frozenset
# capture these to bypass sandboxing # 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 import open as os_open
from os.path import isdir, split from os.path import isdir, split
...@@ -36,6 +43,8 @@ _distribute = True ...@@ -36,6 +43,8 @@ _distribute = True
def _bypass_ensure_directory(name, mode=0777): def _bypass_ensure_directory(name, mode=0777):
# Sandbox-bypassing version of ensure_directory() # Sandbox-bypassing version of ensure_directory()
if not WRITE_SUPPORT:
raise IOError('"os.mkdir" not supported on this platform.')
dirname, filename = split(name) dirname, filename = split(name)
if dirname and filename and not isdir(dirname): if dirname and filename and not isdir(dirname):
_bypass_ensure_directory(dirname) _bypass_ensure_directory(dirname)
...@@ -1332,6 +1341,10 @@ class ZipProvider(EggProvider): ...@@ -1332,6 +1341,10 @@ class ZipProvider(EggProvider):
timestamp = time.mktime(date_time) timestamp = time.mktime(date_time)
try: try:
if not WRITE_SUPPORT:
raise IOError('"os.rename" and "os.unlink" are not supported '
'on this platform')
real_path = manager.get_cache_path( real_path = manager.get_cache_path(
self.egg_name, self._parts(zip_path) self.egg_name, self._parts(zip_path)
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment