[pypy-svn] r71864 - in pypy/branch/ctypes-configure-cache-2/pypy: lib/ctypes_config_cache translator/goal

arigo at codespeak.net arigo at codespeak.net
Sat Mar 6 14:16:28 CET 2010


Author: arigo
Date: Sat Mar  6 14:16:27 2010
New Revision: 71864

Modified:
   pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/rebuild.py
   pypy/branch/ctypes-configure-cache-2/pypy/translator/goal/targetpypystandalone.py
Log:
Tweaks.


Modified: pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/rebuild.py
==============================================================================
--- pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/rebuild.py	(original)
+++ pypy/branch/ctypes-configure-cache-2/pypy/lib/ctypes_config_cache/rebuild.py	Sat Mar  6 14:16:27 2010
@@ -3,9 +3,14 @@
 
 import autopath
 import os, sys
+import py
 
 _dirpath = os.path.dirname(__file__)
 
+from pypy.tool.ansi_print import ansi_log
+log = py.log.Producer("ctypes_config_cache")
+py.log.setconsumer("ctypes_config_cache", ansi_log)
+
 
 def rebuild_one(name):
     filename = os.path.join(_dirpath, name)
@@ -17,19 +22,20 @@
     finally:
         sys.path[:] = path
 
-def rebuild(log=None):
+def try_rebuild():
+    for p in os.listdir(_dirpath):
+        if p.startswith('_') and (p.endswith('_cache.py') or
+                                  p.endswith('_cache.pyc')):
+            os.unlink(os.path.join(_dirpath, p))
     for p in os.listdir(_dirpath):
         if p.endswith('.ctc.py'):
             try:
                 rebuild_one(p)
             except Exception, e:
-                if log is None:
-                    raise
-                else:
-                    log.ERROR("Running %s:\n  %s: %s" % (
-                        os.path.join(_dirpath, p),
-                        e.__class__.__name__, e))
+                log.ERROR("Running %s:\n  %s: %s" % (
+                    os.path.join(_dirpath, p),
+                    e.__class__.__name__, e))
 
 
 if __name__ == '__main__':
-    rebuild()
+    try_rebuild()

Modified: pypy/branch/ctypes-configure-cache-2/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/branch/ctypes-configure-cache-2/pypy/translator/goal/targetpypystandalone.py	(original)
+++ pypy/branch/ctypes-configure-cache-2/pypy/translator/goal/targetpypystandalone.py	Sat Mar  6 14:16:27 2010
@@ -217,8 +217,7 @@
     
     def get_entry_point(self, config):
         from pypy.lib.ctypes_config_cache import rebuild
-        import translate
-        rebuild.rebuild(translate.log)
+        rebuild.try_rebuild()
 
         space = make_objspace(config)
 



More information about the Pypy-commit mailing list