Extending python.

Discussion in 'Python' started by Grzegorz Dostatni, Aug 6, 2004.

  1. Cheers.

    More questions.
    Let's say I'm trying to extend python with a c module. That module cannot
    be dynamically loaded (for reasons outside my control). I have to create a
    custom python executable (or more likely custom python library).
    How would I do that? Is there documentation on that somewhere? Most of
    what I've seen was for dynamic loading.

    2nd Step:
    Let's say I'm doing it under windows, using Visual Studio. Is there
    anything I have to be aware of?

    3rd Step:
    Let's say I don't have the source available. I do have the object files,
    the resulting libraries and the header files though.

    Greg

    "The optimist proclaims that we live in the best of all possible worlds,
    and the pessimist fears this is true."
    - James Branch Cabell
    Grzegorz Dostatni, Aug 6, 2004
    #1
    1. Advertising

  2. Grzegorz Dostatni

    xzm Guest

    I think you may create custom python exe... something like the
    following and just link against your module and python2x.lib. Of
    course, you still need to do the usual stuffs of wrapping around you
    own C code. Then you may just 'import xyz' in Python:

    #include "Python.h"
    #include "xyzmodule.h"

    int main(int argc, char **argv)
    {
    PyImport_AppendInittab("xyz", initxyz);
    return Py_Main(argc, argv);
    }



    Grzegorz Dostatni <> wrote in message news:<>...
    > Cheers.
    >
    > More questions.
    > Let's say I'm trying to extend python with a c module. That module cannot
    > be dynamically loaded (for reasons outside my control). I have to create a
    > custom python executable (or more likely custom python library).
    > How would I do that? Is there documentation on that somewhere? Most of
    > what I've seen was for dynamic loading.
    >
    > 2nd Step:
    > Let's say I'm doing it under windows, using Visual Studio. Is there
    > anything I have to be aware of?
    >
    > 3rd Step:
    > Let's say I don't have the source available. I do have the object files,
    > the resulting libraries and the header files though.
    >
    > Greg
    >
    > "The optimist proclaims that we live in the best of all possible worlds,
    > and the pessimist fears this is true."
    > - James Branch Cabell
    xzm, Aug 7, 2004
    #2
    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. John D

    Extending the python language

    John D, Sep 16, 2003, in forum: Python
    Replies:
    1
    Views:
    297
    Simon Burton
    Sep 17, 2003
  2. Luke
    Replies:
    3
    Views:
    507
    Robin Becker
    Oct 24, 2003
  3. Johannes Zellner
    Replies:
    1
    Views:
    331
    Fredrik Lundh
    Jan 18, 2006
  4. Kiran
    Replies:
    5
    Views:
    283
    Kiran
    Oct 26, 2006
  5. Kiran
    Replies:
    3
    Views:
    625
    Kiran
    Oct 26, 2006
Loading...

Share This Page