From: Michael F. <fuz...@vo...> - 2007-11-21 23:39:11
|
Python.NET provides a managed wrapper around the CPython embedding API. This allows you to easily (relatively) embed CPython in a .NET application. The wrapper is 'Python.Runtime.dll' and is dependent on having python24.dll (or whatever) available... Michael http://www.manning.com/foord Mark McMahon wrote: > Hi, > > So in fact you will be embedding Python in the .NET app. > > You will need to do a lot more than you are trying to do below. I would suggest looking at Pyrex to create some C code that will create the required DLL exported functions/classes (though I don't think there are tools to automatically take the Python code and create a Pyrex or C wrapper for it). > > Some hints (though maybe I should write up what I have done a few times :) > - You need to initialize Python AND your module in the LibMain method > - The Pyrex functions will just forward their calls to the underlying Python code (e.g. if there is a function paramiko.DoSomething(arg1, arg2, arg3), then your Pyrex code should have a similar function and just call the paramiko function. > - If a paramiko function uses duck typing or allows you to pass in different types for a parameter then you will need to decide which signature to expose to .NET (or even create multiple functions to make all available - if that was necessary). Remember that C (and thus DLL functions) have no overloading/duck typing. > - Is paramiko pure python? (it seems it is from their home page) so it might be easier to do something with IronPython or Python.NET (though I am not sure about how well those allow you to make stuff available to other .NET languages - maybe they just let python access other .NET components). > > Sorry - it's 6:30 in the evening just before thanksgiving (though I am not American, I live here) and the office is empty and I feel tired ;) > > If this is something you wish to pursue - then I can try to help you, > Thanks > Mark > > > -----Original Message----- > From: py2...@li... [mailto:py2...@li...] On Behalf Of john saponara > Sent: Wednesday, November 21, 2007 11:15 AM > To: py2...@li... > Subject: [Py2exe-users] create dll from module? > > How can I create a dll from a python module? I need to make the > interface of paramiko (a third party sftp module at > http://www.lag.net/paramiko/) visible to a coworker's dotnet code, so I > want to convert the module (and its dependencies) into a dll. > > I thought the ShippingEmbedded page (under tips and tricks) might help. > It says to create a module-less setup.py: > > from distutils.core import setup > import py2exe > setup() > > and then include the module on the commandline; in my case: > > python setup.py py2exe --includes paramiko > > but the resulting dist folder had no 'paramiko.dll'. I assume the code > I want is sitting in library.zip. Is there a way to expose it as a dll? > > Thanks, > John > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users > > |