2012-03-07 67 views
2

平臺:Windows 7 假設兩者的32位版本。pythondotnet可以使用堆棧python 2.7.2嗎?

我目前的理解是,這是不可能的,因爲這兩個安裝過程涉及替換python.exe本身。

我猜每個源都需要合併才能從兩者獲得功能?

無堆棧的Python: http://zope.stackless.com/

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

我們正在使用的Python .NET在IronPython的,因爲我們希望獲得全方位的CPython庫(如等matplotlib) 。

回答

1

原來pythondotnet有一個選項,您不必更換exe。這在這裏的「入門」部分簡要提及: http://pythonnet.github.io/readme

這允許您然後執行無堆棧安裝(修改EXE)並仍然獲得pythondotnet功能。

clr.pyd和Python.Runtime.dll文件最終複製到Python27/DLL目錄中,而不是將這兩個文件和修改的python.exe複製到根python安裝目錄中。

這一切都是用x86完成的,順便說一句... x64支持適用於pythondotnet,但無法獲得無堆棧x64支持工作......從源代碼構建之後運行x64解釋器,但像numpy這樣的庫出現故障。

2

正如你所說 - 不,這是不可能的:兩個項目的「合併源」也是一項不平凡的任務。

但是,sicne你有一個很好處理堆棧的問題,我建議編寫你的項目中需要寫入堆棧Python的部分,以及需要的另一部分項目。 net使用常規的IronPython - 你可以使用xmlrpc(或jsonrpc)調用在程序的兩部分之間交換數據 - 在Python中這不是一件複雜的事情,並且可以在Python中使用(例如:http://code.activestate.com/recipes/81549-a-simple-xml-rpc-server/

+0

不好的建議,不幸的是,這將不適用於我們的應用程序。可能還有另外一種可能性。如果能解決問題,將會發布。謝謝。 – 2012-03-07 21:58:41

+0

2016更新 - 做這種事情的自然Python「方式」是芹菜(http://www.celeryproject.org/) – jsbueno 2016-02-04 11:59:56

1

對於任何尋求正式答案的人來說,這是「不」。 PythonDotNet遍歷Python對象的內部工作。

/// <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