[Pythonmac-SIG] distutils/swig - Loaded module does not contain symbol...

Bob Ippolito bob at redivi.com
Sun Apr 3 20:06:52 CEST 2005


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



More information about the Pythonmac-SIG mailing list