Is it possible to write a DLL using python

Discussion in 'Python' started by AMD, Aug 17, 2004.

  1. AMD

    AMD Guest

    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
     
    AMD, Aug 17, 2004
    #1
    1. Advertising

  2. AMD

    Phil Frost Guest

    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:
    > 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
     
    Phil Frost, Aug 17, 2004
    #2
    1. Advertising

  3. AMD

    Paul Morrow Guest

    AMD wrote:

    > 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



    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.
     
    Paul Morrow, Aug 17, 2004
    #3
  4. AMD

    Paul Miller Guest

    AMD <> wrote in message news:<cft24m$njb$>...

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


    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.
     
    Paul Miller, Aug 17, 2004
    #4
  5. AMD

    Robin Becker Guest

    Paul Miller wrote:
    > AMD <> wrote in message news:<cft24m$njb$>...
    >
    >
    >>I need to write a Win32 DLL and I would like to use Python instead of
    >>VB, C++ or Delphi. Is this possible?

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


    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
     
    Robin Becker, Aug 18, 2004
    #5
  6. AMD

    AMD Guest

    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

    > 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:
    >
    >>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
     
    AMD, Aug 18, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    8,774
  2. Krzysiek
    Replies:
    2
    Views:
    528
    Krzysiek
    Jul 5, 2004
  3. MiLF
    Replies:
    5
    Views:
    1,219
    D. Rush
    Sep 30, 2004
  4. Giles Brown
    Replies:
    4
    Views:
    846
    Giles Brown
    Jul 30, 2003
  5. H. Simpson
    Replies:
    4
    Views:
    282
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page