Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 18th, 2005, 02:57 PM
AMD
Guest
 
Posts: n/a
Default Is it possible to write a DLL using python

Hi,

I need to write a Win32 DLL and I would like to use Python instead of
VB, C++ or Delphi. Is this possible?

Thank you,

Andre M. Descombes
  #2  
Old July 18th, 2005, 02:58 PM
Phil Frost
Guest
 
Posts: n/a
Default Re: Is it possible to write a DLL using python

Not directly, but yes, using libpython. Essentially you write your
python code and then a thin C wrapper over it that does datatype and
calling convention conversion. Since this is not a pleasant task for
many people, you might take a look at Pyrex, which does this quite
nicely. Generally Pyrex is considered as a way to wrap C code for use
but Python, but it works just as well the other way.

On Tue, Aug 17, 2004 at 03:44:50PM +0200, AMD wrote:[color=blue]
> Hi,
>
> I need to write a Win32 DLL and I would like to use Python instead of
> VB, C++ or Delphi. Is this possible?
>
> Thank you,
>
> Andre M. Descombes[/color]
  #3  
Old July 18th, 2005, 02:58 PM
Paul Morrow
Guest
 
Posts: n/a
Default Re: Is it possible to write a DLL using python

AMD wrote:
[color=blue]
> Hi,
>
> I need to write a Win32 DLL and I would like to use Python instead of
> VB, C++ or Delphi. Is this possible?
>
> Thank you,
>
> Andre M. Descombes[/color]


The new version of py2exe
(http://starship.python.net/crew/theller/py2exe/) supposedly allows the
creation of dll com servers if that's of interest to you.

  #4  
Old July 18th, 2005, 02:59 PM
Paul Miller
Guest
 
Posts: n/a
Default Re: Is it possible to write a DLL using python

AMD <amdescombes@qualicontrol.com> wrote in message news:<cft24m$njb$1@news-reader2.wanadoo.fr>...
[color=blue]
> I need to write a Win32 DLL and I would like to use Python instead of
> VB, C++ or Delphi. Is this possible?[/color]

No. It is possible to interface to and from Python via other
languages, but since Python does not create native code, you cannot
create a DLL with it.
  #5  
Old July 18th, 2005, 03:00 PM
Robin Becker
Guest
 
Posts: n/a
Default Re: Is it possible to write a DLL using python

Paul Miller wrote:[color=blue]
> AMD <amdescombes@qualicontrol.com> wrote in message news:<cft24m$njb$1@news-reader2.wanadoo.fr>...
>
>[color=green]
>>I need to write a Win32 DLL and I would like to use Python instead of
>>VB, C++ or Delphi. Is this possible?[/color]
>
>
> No. It is possible to interface to and from Python via other
> languages, but since Python does not create native code, you cannot
> create a DLL with it.[/color]

This is not strictly true. At work I have made DLLs which encapsulate
the base python code and then link themselves to a specialized version
of Python (to avoid clashes with any other python). At the extreme we
made a Darwin shared library which encapsulated our application code and
the whole of python. I made use(misuse probably) of the freeze tool to
accomplish this latter. The result was a single binary .so with a simple
interface that used python internally.

Python doesn't make this easy (the startup is fairly complex), but it is
possible.
--
Robin Becker
  #6  
Old July 18th, 2005, 03:00 PM
AMD
Guest
 
Posts: n/a
Default Re: Is it possible to write a DLL using python

Actually what I need to do is write a DLL which exports a single stdCall
method named Execute which receives an IDispatch interface to the caller
as its only parameter:

Here is the equivalent Delphi declaration of the method I need to export :

procedure Execute(caller IDispatch); stdcall;

I will take a look at Pyrex and Py2Exe and see if they can help me.

Regards,

Andre
[color=blue]
> Not directly, but yes, using libpython. Essentially you write your
> python code and then a thin C wrapper over it that does datatype and
> calling convention conversion. Since this is not a pleasant task for
> many people, you might take a look at Pyrex, which does this quite
> nicely. Generally Pyrex is considered as a way to wrap C code for use
> but Python, but it works just as well the other way.
>
> On Tue, Aug 17, 2004 at 03:44:50PM +0200, AMD wrote:
>[color=green]
>>Hi,
>>
>>I need to write a Win32 DLL and I would like to use Python instead of
>>VB, C++ or Delphi. Is this possible?
>>
>>Thank you,
>>
>>Andre M. Descombes[/color][/color]
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles