How do I pass structures using a C extension?

timothy.williams at nvl.army.mil timothy.williams at nvl.army.mil
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 setup.py 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])
OTB_HOME='/vps/otbknox/williams/OTB_2.0'
OTB_INCLDIR=[
    os.path.join(OTB_HOME, 'include', 'global'),
    os.path.join(OTB_HOME, 'include', 'libinc'),
    os.path.join(sys.prefix,'include',py_version),
    OTB_HOME
    ]
libsrcs=glob.glob(os.path.join(OTB_HOME,'libsrc','libcmdline','*.c'))

setup (name = 'OTB_libs',
       version='1.0',
       author="Tim Williams",
##       packages=['cmdline'],
##       ext_package='OTB_libs',
       ext_modules=[Extension('_cmdline',
                              sources=['cmdline.i']+ libsrcs,
                              include_dirs=OTB_INCLDIR
                              )
                    ]
       )


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