How do I pass structures using a C extension?

timothy.williams at timothy.williams at
Tue Mar 15 15:50:52 CET 2005

I have access to the source, so it seems that I can create shareable
libs for the libraries I want to use using distutils. I do a
glob.glob() on the *.c files in the libscr directory.  If I copy the
main library.h file over to where my module.i file is, I can do a
%include on it and things seem to get built fine. (I still need to
actually call something to see if it works.)

Is there a way to change my file to look in the locations
specified by the 'include_dirs' argument? This argument works for my C
compiling, but it doesn't get passed to swig.

#!/bin/env python
import sys, os, glob
from distutils.core import setup, Extension

py_version='python%d.%d' % (sys.version_info[0],sys.version_info[1])
    os.path.join(OTB_HOME, 'include', 'global'),
    os.path.join(OTB_HOME, 'include', 'libinc'),

setup (name = 'OTB_libs',
       author="Tim Williams",
##       packages=['cmdline'],
##       ext_package='OTB_libs',
                              sources=['cmdline.i']+ libsrcs,

running build
running build_ext
building '_cmdline' extension
swigging cmdline.i to cmdline_wrap.c
swig -python -o cmdline_wrap.c cmdline.i
cmdline.i:9: Unable to find 'libcmdline.h'
error: command 'swig' failed with exit status 1

More information about the Python-list mailing list