[Distutils] How do I modify the swig options in my setup.py

Lars Immisch lars at ibp.de
Wed Mar 16 20:46:01 CET 2005


> I'm trying to use SWIG to create an extension to access some third party
> libraries I want to be able to change the options to include possible
> '-includeall', '-c++'.  I'm using distutils,  but I don't know how to change
> from the default options.

 From inside setup.py, use swig_opts. See the following example:

import sys
from distutils.core import setup,Extension

setup (name = "sai",
        version = "2.0",
        description = "SAI Python wrapper",
        author = "Lars Immisch",
        author_email = "lars at ibp.de",
        ext_modules = [Extension("_sai", ["sai.i",
                                          "errorobject.c",
                                          "symname.c"],
                                 swig_opts = [ "-modern", "-new_repr",
                                               "-I..", "-I../../include"],
                                 include_dirs=["..", "../../include"],
                                 library_dirs=["."],
                                 libraries=["nsl", "pthread",
                                            "cSARU-genappl-api", "saru"])],
        py_modules = ['sai']
        )


> Also, a SWIG question: i build my _module.so and module_wrap.o, but when I
> try to call one of the functions, I get and error saying that the last
> argument was expected to be a pointer, but it isn't. I tried calling a
> couple of functions and both times SWIG is expecting the last arg to be a
> pointer. Any ideas?

Wrong typemaps ;-)

This sort of question is best asked with a minimal example on the swig 
mailing list, but do have a look into typemaps in the documentation.

A lot of useful typemaps are in python/typemaps.i.

- Lars


More information about the Distutils-SIG mailing list