[Pythonmac-SIG] Solution to some SWIG Install problems on Mac OS X
managan at llnl.gov
Wed Dec 14 19:43:24 CET 2005
>I'd love to see an example. Does it run SWIG for you too?
> > Is distutils more for distributing packages/modules than developing?
YES! I have not gotten Ippolito's reference to setuptools working yet
on my system but I do have a setup.py that runs SWIG. Distutils has
limited support for SWIG in it. The problem is that SWIG gets run
(and creates the shadow .py file) after distutils has already handled
.py files. So you have to either do "python setup.py" twice or
explicitly do "python setup.py build_ext install" so that the
build_ext command runs SWIG and builds the extension module and then
install goes back and copies everything where it needs to go.
Here is a simple setup.py for this (somewhat modified from mine to
make it generic but it should work). If you need to add source files
beyond what SWIG produces I think you add them to the list that has
"package + '.i'" in it.
from distutils.core import setup, Extension
# package is the the module name and the name of the SWIG .i file
# Probably good to use the same in py_modules at the bottom.
package = 'mymodule'
version = '0.1'
# add any directories to search for include files
include_dirs = ['../src',]
# add any directories to search for libraries
lib_dirs = ['.',]
# add any libraries name to link against
libraries = ['readline','termcap','X11']
#extra_comp_args = 
extra_comp_args = ['-Wno-strict-prototypes',]
setup(name = package,
version = version,
description = '',
author = 'My Name',
author_email = 'myname at somewhere.com',
url = 'http://',
ext_modules = [Extension('_'+package,
py_modules = ['mymodule',]
Rob Managan email managan at llnl.gov
LLNL phone: 925-423-0903
P.O. Box 808, L-095 FAX: 925-422-3389
Livermore, CA 94551-0808
More information about the Pythonmac-SIG