Question

Platform: Windows 7 Assume 32bit versions of both.

My current understanding is that it is NOT possible since both installation processes involve replacing the python.exe itself.

I guess the source for each would have to be merged in order to get functionality from both?

Stackless Python: http://zope.stackless.com/

Python for .NET: http://pythonnet.github.io/

We are using Python for .NET over IronPython since we want access to the full range of cpython libraries (e.g. matplotlib among others).

Was it helpful?

Solution 3

Turns out there is an option for pythondotnet where you don't have to replace the exe. This is mentioned briefly in the "getting started" section here: http://pythonnet.github.io/readme

This allows you to then do the install of stackless (modifying the exe) and still get the pythondotnet functionality.

The clr.pyd and Python.Runtime.dll files end up getting copied into the Python27/DLLs directory instead of copying both of these files and a modified python.exe into the root python install directory.

This was all done with x86, btw... the x64 support works for pythondotnet but could not get the stackless x64 support to work... got the x64 interpreter to run after building from source but libraries like numpy appeared broken.

OTHER TIPS

As you state - no, this is not possible: "merging the source" of both projects would be a non-trivial task, as well.

However, sicne you have a problem that is well handled with stackless, I'd suggest to write the part of your project that do need stackless Python to be written in it, and another part of your project, which needs .net to use the regular IronPython - you can comunicate data between the two parts of the program using xmlrpc (or jsonrpc) calls -- it is not a complicated thing to do in Python, and would work in both Python flavors (example here: http://code.activestate.com/recipes/81549-a-simple-xml-rpc-server/ )

For anyone seeking the official answer, it's "No". PythonDotNet steps all over the internal workings of Python's Object.

/// <summary>
/// TypeFlags(): The actual bit values for the Type Flags stored
/// in a class.
/// Note that the two values reserved for stackless have been put
/// to good use as PythonNet specific flags (Managed and Subclass)
/// </summary>
internal class TypeFlags {
    public static int HaveGetCharBuffer = (1 << 0);
    public static int HaveSequenceIn = (1 << 1);
    public static int GC = 0;
    public static int HaveInPlaceOps = (1 << 3);
    public static int CheckTypes = (1 << 4);
    public static int HaveRichCompare = (1 << 5);
    public static int HaveWeakRefs = (1 << 6);
    public static int HaveIter = (1 << 7);
    public static int HaveClass = (1 << 8);
    public static int HeapType = (1 << 9);
    public static int BaseType = (1 << 10);
    public static int Ready = (1 << 12);
    public static int Readying = (1 << 13);
    public static int HaveGC = (1 << 14);
    // 15 and 16 are reserved for stackless <- quote from the python source
    public static int HaveStacklessExtension = 0;
    /* XXX Reusing reserved constants */
    public static int Managed = (1 << 15); // PythonNet specific
    public static int Subclass = (1 << 16); // PythonNet specific
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top