On Apr 3, 2005, at 5:19 AM, Larry Bugbee wrote:

On Apr 3, 2005, at 12:55 AM, Bob Ippolito wrote:


On Apr 3, 2005, at 4:12 AM, Larry Bugbee wrote:

I'm stuck. I'm trying to make a Python extension from some relatively simple code written in C. I created a setup.py and built the module. Upon importing, I keep getting an ImportError. I built and got the same error with both python 2.3 and 2.4.1. (I am running 10.3.8. swig is 1.3.24. gcc is 3.3.)

Going back to basics I created an even simpler test case with the same results.

arith.c
=======
int add(int a, int b) {
                return a+b;
}

arith.i
=======
%module arith
int add(int a, int b);

setup.py
========
import distutils
from distutils.core import setup, Extension
setup(name = 'arith',
      version = '1.0',
      ext_modules = [Extension('arith', ['arith.i', 'arith.c'])])


python setup.py install >>>import arith

from distutils.core import setup, Extension setup( name='arith', version='1.0', ext_modules=[ # swig generates arith.py -- so extension is _arith.so Extension('_arith', ['arith.i', 'arith.c']), ], )

Thanks Bob! ...that combined with arith.py not being copied to site-package.

Which raises another question, ought not arith.py be copied and if so, a bug?

Anyway, much appreciated. I'm off and running again. Thanks.

You have to specify that as well, of course. I forget what the setup kwarg is for plain modules, though.


-bob

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to