Is it possible to write a DLL using python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AMD

    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
  • Phil Frost

    #2
    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]

    Comment

    • Paul Morrow

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

      Comment

      • Paul Miller

        #4
        Re: Is it possible to write a DLL using python

        AMD <amdescombes@qu alicontrol.com> wrote in message news:<cft24m$nj b$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.

        Comment

        • Robin Becker

          #5
          Re: Is it possible to write a DLL using python

          Paul Miller wrote:[color=blue]
          > AMD <amdescombes@qu alicontrol.com> wrote in message news:<cft24m$nj b$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

          Comment

          • AMD

            #6
            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]

            Comment

            Working...