[pypy-svn] r71847 - pypy/branch/ctypes-configure-cache/pypy/lib

fijal at codespeak.net fijal at codespeak.net
Sat Mar 6 05:31:09 CET 2010


Author: fijal
Date: Sat Mar  6 05:31:06 2010
New Revision: 71847

Modified:
   pypy/branch/ctypes-configure-cache/pypy/lib/syslog.py
Log:
use caching for syslog


Modified: pypy/branch/ctypes-configure-cache/pypy/lib/syslog.py
==============================================================================
--- pypy/branch/ctypes-configure-cache/pypy/lib/syslog.py	(original)
+++ pypy/branch/ctypes-configure-cache/pypy/lib/syslog.py	Sat Mar  6 05:31:06 2010
@@ -6,13 +6,12 @@
 """
 
 import sys
+import os.path
 if sys.platform == 'win32':
     raise ImportError("No syslog on Windows")
 
-from ctypes_support import standard_c_lib as libc
+from ctypes_support import standard_c_lib as libc, cache_dir
 from ctypes import c_int, c_char_p
-from ctypes_configure.configure import (configure,
-    ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger)
 
 _CONSTANTS = (
     'LOG_EMERG',
@@ -61,14 +60,23 @@
     ('LOG_UUCP', 'LOG_MAIL'),
 )
 
-class SyslogConfigure:
-    _compilation_info_ = ExternalCompilationInfo(includes=['sys/syslog.h'])
-for key in _CONSTANTS:
-    setattr(SyslogConfigure, key, ConstantInteger(key))
-for key in _OPTIONAL_CONSTANTS:
-    setattr(SyslogConfigure, key, DefinedConstantInteger(key))
+cache_file = os.path.join(cache_dir, 'syslog')
+try:
+    config = {}
+    execfile(cache_file, config)
+except (IOError, OSError):
+    from ctypes_configure.configure import (configure,
+        ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger)
+
+    class SyslogConfigure:
+        _compilation_info_ = ExternalCompilationInfo(includes=['sys/syslog.h'])
+    for key in _CONSTANTS:
+        setattr(SyslogConfigure, key, ConstantInteger(key))
+    for key in _OPTIONAL_CONSTANTS:
+        setattr(SyslogConfigure, key, DefinedConstantInteger(key))
+
+    config = configure(SyslogConfigure, savecache=cache_file)
 
-config = configure(SyslogConfigure)
 for key in _CONSTANTS:
     globals()[key] = config[key]
 optional_constants = []



More information about the Pypy-commit mailing list