Source

pypy / ctypes_configure / cbuild.py

Diff from to

ctypes_configure/cbuild.py

 
 import os, sys, inspect, re, imp, py
 from ctypes_configure import stdoutcapture
+import distutils
 
 debug = 0
 
-log = py.log.Producer("cbuild")
-
-configdir = py.path.local.make_numbered_dir(prefix='ctypes_configure')
+configdir = py.path.local.make_numbered_dir(prefix='ctypes_configure-')
 
 class ExternalCompilationInfo(object):
 
         opt += '/Op'
     gcv['OPT'] = opt
 
+
+def try_compile(c_files, eci):
+    try:
+        build_executable(c_files, eci)
+        result = True
+    except (distutils.errors.CompileError,
+            distutils.errors.LinkError):
+        result = False
+    return result
+
 def compile_c_module(cfiles, modbasename, eci, tmpdir=None):
     #try:
     #    from distutils.log import set_threshold
 
 def log_spawned_cmd(spawn):
     def spawn_and_log(cmd, *args, **kwds):
-        log.execute(' '.join(cmd))
+        if debug:
+            print ' '.join(cmd)
         return spawn(cmd, *args, **kwds)
     return spawn_and_log
 
         data = ''
         try:
             saved_environ = os.environ.copy()
+            c = stdoutcapture.Capture(mixed_out_err = True)
             try:
-                c = stdoutcapture.Capture(mixed_out_err = True)
                 self._build()
             finally:
                 # workaround for a distutils bugs where some env vars can