[pypy-svn] r71850 - in pypy/branch/ctypes-configure-cache-2: ctypes_configure pypy/lib pypy/lib/ctypes_config_cache

arigo at codespeak.net arigo at codespeak.net
Sat Mar 6 12:16:00 CET 2010


Author: arigo
Date: Sat Mar  6 12:15:59 2010
New Revision: 71850

Added:
   pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/   (props changed)
   pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/__init__.py   (contents, props changed)
   pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/autopath.py
      - copied unchanged from r71849, pypy/branch/ctypes-configure-cache-2/pypy/bin/autopath.py
   pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/syslog.ctc.py   (contents, props changed)
Removed:
   pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_configure
Modified:
   pypy/branch/ctypes-configure-cache-2/ctypes_configure/configure.py
   pypy/branch/ctypes-configure-cache-2/pypy/lib/syslog.py
Log:
Write just enough to have the syslog version.  Note that
'pypy/lib/ctypes_configure' is killed now.  Also note that the cache is
not generated automatically; you have to call 'syslog.ctc.py'
explicitly.  The idea is to call all .ctc.py files at the start of a
translation.


Modified: pypy/branch/ctypes-configure-cache-2/ctypes_configure/configure.py
==============================================================================
--- pypy/branch/ctypes-configure-cache-2/ctypes_configure/configure.py	(original)
+++ pypy/branch/ctypes-configure-cache-2/ctypes_configure/configure.py	Sat Mar  6 12:15:59 2010
@@ -588,6 +588,19 @@
 
 # ____________________________________________________________
 
+def dumpcache(referencefilename, filename, config):
+    dirname = os.path.dirname(referencefilename)
+    filename = os.path.join(dirname, filename)
+    f = open(filename, 'w')
+    names = config.keys()
+    names.sort()
+    for name in names:
+        print >> f, '%s = %r' % (name, config[name])
+    f.close()
+    print 'Wrote %s.' % (filename,)
+
+# ____________________________________________________________
+
 def get_python_include_dir():
     from distutils import sysconfig
     gcv = sysconfig.get_config_vars()

Added: pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/__init__.py
==============================================================================

Added: pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/syslog.ctc.py
==============================================================================
--- (empty file)
+++ pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/syslog.ctc.py	Sat Mar  6 12:15:59 2010
@@ -0,0 +1,79 @@
+"""
+'ctypes_configure' source for syslog.py.
+Run this to rebuild _syslog_cache.py.
+"""
+
+import autopath
+from ctypes_configure.configure import (configure, dumpcache,
+    ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger)
+
+
+_CONSTANTS = (
+    'LOG_EMERG',
+    'LOG_ALERT',
+    'LOG_CRIT',
+    'LOG_ERR',
+    'LOG_WARNING',
+    'LOG_NOTICE',
+    'LOG_INFO',
+    'LOG_DEBUG',
+
+    'LOG_PID',
+    'LOG_CONS',
+    'LOG_NDELAY',
+
+    'LOG_KERN',
+    'LOG_USER',
+    'LOG_MAIL',
+    'LOG_DAEMON',
+    'LOG_AUTH',
+    'LOG_LPR',
+    'LOG_LOCAL0',
+    'LOG_LOCAL1',
+    'LOG_LOCAL2',
+    'LOG_LOCAL3',
+    'LOG_LOCAL4',
+    'LOG_LOCAL5',
+    'LOG_LOCAL6',
+    'LOG_LOCAL7',
+)
+_OPTIONAL_CONSTANTS = (
+    'LOG_NOWAIT',
+    'LOG_PERROR',
+
+    'LOG_SYSLOG',
+    'LOG_CRON',
+    'LOG_UUCP',
+    'LOG_NEWS',
+)
+
+# Constant aliases if there are not defined
+_ALIAS = (
+    ('LOG_SYSLOG', 'LOG_DAEMON'),
+    ('LOG_CRON', 'LOG_DAEMON'),
+    ('LOG_NEWS', 'LOG_MAIL'),
+    ('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))
+
+config = configure(SyslogConfigure)
+optional_constants = []
+for key in _OPTIONAL_CONSTANTS:
+    if config[key] is not None:
+        optional_constants.append(key)
+    else:
+        del config[key]
+for alias, key in _ALIAS:
+    if alias in optional_constants:
+        continue
+    config[alias] = config[key]
+    optional_constants.append(alias)
+
+config['optional_constants'] = optional_constants
+dumpcache(__file__, '_syslog_cache.py', config)

Modified: pypy/branch/ctypes-configure-cache-2/pypy/lib/syslog.py
==============================================================================
--- pypy/branch/ctypes-configure-cache-2/pypy/lib/syslog.py	(original)
+++ pypy/branch/ctypes-configure-cache-2/pypy/lib/syslog.py	Sat Mar  6 12:15:59 2010
@@ -9,79 +9,11 @@
 if sys.platform == 'win32':
     raise ImportError("No syslog on Windows")
 
+# load the platform-specific cache made by running syslog.ctc.py
+from ctypes_config_cache._syslog_cache import *
+
 from ctypes_support import standard_c_lib as libc
 from ctypes import c_int, c_char_p
-from ctypes_configure.configure import (configure,
-    ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger)
-
-_CONSTANTS = (
-    'LOG_EMERG',
-    'LOG_ALERT',
-    'LOG_CRIT',
-    'LOG_ERR',
-    'LOG_WARNING',
-    'LOG_NOTICE',
-    'LOG_INFO',
-    'LOG_DEBUG',
-
-    'LOG_PID',
-    'LOG_CONS',
-    'LOG_NDELAY',
-
-    'LOG_KERN',
-    'LOG_USER',
-    'LOG_MAIL',
-    'LOG_DAEMON',
-    'LOG_AUTH',
-    'LOG_LPR',
-    'LOG_LOCAL0',
-    'LOG_LOCAL1',
-    'LOG_LOCAL2',
-    'LOG_LOCAL3',
-    'LOG_LOCAL4',
-    'LOG_LOCAL5',
-    'LOG_LOCAL6',
-    'LOG_LOCAL7',
-)
-_OPTIONAL_CONSTANTS = (
-    'LOG_NOWAIT',
-    'LOG_PERROR',
-
-    'LOG_SYSLOG',
-    'LOG_CRON',
-    'LOG_UUCP',
-    'LOG_NEWS',
-)
-
-# Constant aliases if there are not defined
-_ALIAS = (
-    ('LOG_SYSLOG', 'LOG_DAEMON'),
-    ('LOG_CRON', 'LOG_DAEMON'),
-    ('LOG_NEWS', 'LOG_MAIL'),
-    ('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))
-
-config = configure(SyslogConfigure)
-for key in _CONSTANTS:
-    globals()[key] = config[key]
-optional_constants = []
-for key in _OPTIONAL_CONSTANTS:
-    if config[key] is not None:
-        globals()[key] = config[key]
-        optional_constants.append(key)
-for alias, key in _ALIAS:
-    if alias in optional_constants:
-        continue
-    globals()[alias] = globals()[key]
-    optional_constants.append(alias)
-del config
 
 # Real prototype is:
 # void syslog(int priority, const char *format, ...);



More information about the Pypy-commit mailing list