On Tue, Nov 3, 2009 at 5:00 PM, Stefan Behnel <[email protected]> wrote:
>
> To get there, we'd have to patch
> into distutils, and that's far from trivial as there isn't really a hook to
> do that.
>
The natural hook is monkeypatching distutils.spawn.spawn, I think... Actually:
from distutils import ccompiler # the module
ccompiler.spawn = my_new_posix_spawn
> Another possibility would be to divert stdout/stderr into a pipe when we
> fork. Does anyone know how to do that in Python?
>
pid = os.fork()
if pid = 0:
err = open("filename.ext", 'w')
os.dup2(err.fileno(), sys.stderr.fileno())
try: spawn(cmd)
finally: err.close()
else:
os.wait(pid)
err = open("filename.ext", 'r')
try: data = err.read()
finally: err.close()
Something like that... Actually, we should modify _spawn_posix() in
distutils.spawn adding the os.dup2 stuff. Right now I'm very busy to
implement it, sorry.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev