How do I pass structures using a C extension?
programmer.py at gmail.com
Tue Mar 15 17:55:14 CET 2005
I've never built a swig extension module using distutils. Heck, i've
only rolled up pure python code using it... that's pretty slick..
Oh, anyway, make sure that libcmdline.h is in swigs search path.
Either copy libcmdline.h to $CWD or figure out how to pass -I to swig
-I<dir> - Look for SWIG files in <dir>
You may find it easier to roll the swig wrappers by hand... It's not
that hard really...
On 15 Mar 2005 06:50:52 -0800, timothy.williams at nvl.army.mil
<timothy.williams at nvl.army.mil> wrote:
> 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,sys.version_info)
> 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