newbie-question: extending python with c++

Luigi Ballabio ballabio at mac.com
Tue Apr 16 07:12:53 EDT 2002


At 11:10 AM 4/16/02 +0200, Siegfried Gonzi wrote:
>I think it is not inappropiate to post here the instruction (thought I
>got it due to private mail; but there is no private junk in it and hence
>I believe the original author does not mind: author: Luigi Ballabio; I
>augmented Luigi's B. stuff with the pointer stuff and some other
>explanations).

I don't mind at all. However, there's one point which can be further 
detailed : I didn't in my original post since you specified that you 
weren't using SWIG with the -shadow option.
If one does instead, the shared extension should no longer be called 
example.so but examplec.so, and a Python file example.py is generated.
In this case, the call to setup() should read:

setup(name         = "Example",
        description  = "Example Python extension",
        py_modules   = ["example"],                   # add the .py file
        ext_modules  = [Extension("examplec",         # rename the extension

["C:/Wissenschaft/SWIG-1.3.11/ex/example_wrap.c",
                                   "C:/Wissenschaft/SWIG-1.3.11/ex/example.c"],
                                  libraries = [],
                                  define_macros = [],
                                  include_dirs =
[C:/Wissenschaft/SWIG-1.3.11/ex/],
                                  library_dirs = [],
                                  extra_compile_args = [],
                                  extra_link_args = [])
                       ]
       )

Bye,
         Luigi






More information about the Python-list mailing list