Working with .NET Code Remotely with execnet

Testing is a big topic in Python, with major libraries like py.test and nose pushing forward the state of the art. Even the standard library module unittest has had a lot of improvements that will appear in Python 2.7 and 3.2.

Part of py.test is a library for distributed testing and deployment with remote Python interpreters. This library is called execnet:
The execnet package allows you to:
  • instantiate local/remote Python Interpreters
  • send code for execution to one or many Interpreters
  • send and receive data through channels
execnet performs zero-install bootstrapping into other interpreters; package installation is only required at the initiating side. execnet enables interoperation between CPython 2.4-3.1, Jython 2.5.1, PyPy 1.1 and IronPython and works well on Windows, Linux and OSX systems.
Support of Jython and IronPython are experimental at this point. Feedback and help with testing welcome.
The IronPython support allows you to remotely work with .NET objects / libraries from CPython.
(Experimental) use your CPython interpreter to connect to a IronPython interpreter which can work with C# classes. Here is an example for instantiating a CLR Array instance and sending back its representation:
import execnet
gw = execnet.PopenGateway("ipy")

channel = gw.remote_exec("""
    import clr
    clr.AddReference("System")
    from System import Array
    array = Array[float]([1,2])
    channel.send(str(array))
""")
print (channel.receive())
using Mono 2.0 and IronPython-1.1 this will print on the CPython side:
System.Double[](1.0, 2.0)
Using IronPython needs more testing, likely newer versions will work better. please feedback if you have information.

Comments

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

Should Python Projects Support IronPython and Jython?

Further Adventures of the Debugger