[pypy-svn] r71843 - pypy/branch/ctypes-configure-cache/pypy/lib
fijal at codespeak.net
fijal at codespeak.net
Sat Mar 6 05:10:10 CET 2010
Author: fijal
Date: Sat Mar 6 05:10:08 2010
New Revision: 71843
Modified:
pypy/branch/ctypes-configure-cache/pypy/lib/_locale.py
pypy/branch/ctypes-configure-cache/pypy/lib/ctypes_support.py
pypy/branch/ctypes-configure-cache/pypy/lib/resource.py
Log:
Use caching also in resource
Modified: pypy/branch/ctypes-configure-cache/pypy/lib/_locale.py
==============================================================================
--- pypy/branch/ctypes-configure-cache/pypy/lib/_locale.py (original)
+++ pypy/branch/ctypes-configure-cache/pypy/lib/_locale.py Sat Mar 6 05:10:08 2010
@@ -6,7 +6,7 @@
from ctypes import (Structure, POINTER, create_string_buffer,
c_ubyte, c_int, c_char_p, c_wchar_p)
from ctypes_support import standard_c_lib as libc
-from ctypes_support import get_errno
+from ctypes_support import get_errno, cache_dir
import os.path
@@ -31,13 +31,12 @@
'LC_IDENTIFICATION',
)
-cache_dir = os.path.join(os.path.dirname(__file__), '_ctypes', '_cache')
cache_file = os.path.join(cache_dir, '_locale')
try:
locale_config = {}
execfile(cache_file, locale_config)
-except:
+except (IOError, OSError):
from ctypes_configure.configure import (configure, ExternalCompilationInfo,
ConstantInteger, DefinedConstantInteger, SimpleType)
Modified: pypy/branch/ctypes-configure-cache/pypy/lib/ctypes_support.py
==============================================================================
--- pypy/branch/ctypes-configure-cache/pypy/lib/ctypes_support.py (original)
+++ pypy/branch/ctypes-configure-cache/pypy/lib/ctypes_support.py Sat Mar 6 05:10:08 2010
@@ -6,6 +6,9 @@
import ctypes
import ctypes.util
import sys
+import os.path
+
+cache_dir = os.path.join(os.path.dirname(__file__), '_ctypes', '_cache')
# __________ the standard C library __________
Modified: pypy/branch/ctypes-configure-cache/pypy/lib/resource.py
==============================================================================
--- pypy/branch/ctypes-configure-cache/pypy/lib/resource.py (original)
+++ pypy/branch/ctypes-configure-cache/pypy/lib/resource.py Sat Mar 6 05:10:08 2010
@@ -2,13 +2,11 @@
if sys.platform == 'win32':
raise ImportError('resource module not available for win32')
+import os.path
from ctypes_support import standard_c_lib as libc
-from ctypes_support import get_errno
+from ctypes_support import get_errno, cache_dir
from ctypes import Structure, c_int, c_long, byref, sizeof
from errno import EINVAL, EPERM
-from ctypes_configure.configure import (configure,
- ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger,
- SimpleType)
import _structseq
class error(Exception):
@@ -53,16 +51,28 @@
_getpagesize = None
# Setup our configure
-class ResourceConfigure:
- _compilation_info_ = ExternalCompilationInfo(includes=['sys/resource.h'])
- rlim_t = SimpleType('rlim_t')
-for key in _CONSTANTS:
- setattr(ResourceConfigure, key, ConstantInteger(key))
-for key in _OPTIONAL_CONSTANTS:
- setattr(ResourceConfigure, key, DefinedConstantInteger(key))
+
+cache_file = os.path.join(cache_dir, 'resource')
+try:
+ config = {}
+ execfile(cache_file, config)
+except (IOError, OSError):
+ from ctypes_configure.configure import (configure,
+ ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger,
+ SimpleType)
+
+ class ResourceConfigure:
+ _compilation_info_ = ExternalCompilationInfo(
+ includes=['sys/resource.h'])
+ rlim_t = SimpleType('rlim_t')
+ for key in _CONSTANTS:
+ setattr(ResourceConfigure, key, ConstantInteger(key))
+ for key in _OPTIONAL_CONSTANTS:
+ setattr(ResourceConfigure, key, DefinedConstantInteger(key))
+
+ config = configure(ResourceConfigure, savecache=cache_file)
# Configure constants and types
-config = configure(ResourceConfigure)
rlim_t = config['rlim_t']
sizeof_rlim_t = 1<<(sizeof(rlim_t) * 8)
for key in _CONSTANTS:
More information about the Pypy-commit
mailing list