Embedding Python with Dynamic Loading (win)

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

    Embedding Python with Dynamic Loading (win)

    Hi,

    I'm trying to embed python into my application, and have everything
    working fine using the static import lib. However, I don't want my
    application to be dependant on python being installed (it's an
    optional script interpreter). Therefore I want to be able to
    dynamically load python instead (which I believe is possible, but I
    can't find any examples for). It seems, however, that the import lib
    is imported in python.h using a pragma statement.

    1. Is there any suggested way to prevent this import without modifying
    python.h?

    2. Does anyone have a modified python.h which uses LoadLibrary /
    dlopen that they'd be willing to share to save me from writing my own?

    3. Has anyone had any success dynamically loading python and using
    swig modules in the same process (just to check I'm not insane for
    trying this)?

    thanks in advance,

    Simon.

    --
    Simon Steele
    Programmers Notepad - http://www.pnotepad.org/
  • Jeff Epler

    #2
    Re: Embedding Python with Dynamic Loading (win)

    Simon,
    I have heard that vim can use dlopen() (the unix equivalent of
    LoadLibrary) to run Python extensions if it's configured that way. You
    might want to look at their code.

    Jeff

    Comment

    • Michael Geary

      #3
      Re: Embedding Python with Dynamic Loading (win)

      Simon Steele wrote:[color=blue]
      > I'm trying to embed python into my application, and have
      > everything working fine using the static import lib.
      > However, I don't want my application to be dependant on
      > python being installed (it's an optional script interpreter).
      > Therefore I want to be able to dynamically load python
      > instead (which I believe is possible, but I can't find any
      > examples for). It seems, however, that the import lib is
      > imported in python.h using a pragma statement.
      >
      > 1. Is there any suggested way to prevent this import
      > without modifying python.h?[/color]

      Assuming you're using Visual C++, you could use delay loading, which
      essentially converts any imported DLL to use LoadLibrary/GetProcAddress
      without requiring any code changes.



      or



      -Mike


      Comment

      Working...