Python, SWIG and other strange things

Posted by wanderameise on Stack Overflow See other posts from Stack Overflow or by wanderameise
Published on 2010-03-14T11:46:37Z Indexed on 2010/03/14 11:55 UTC
Read the original article Hit count: 466

Filed under:
|
|
|

hey,

I have a firmware for an USB module I can already control by visual C. Now I want to port this to python. for this I need the octopus library which is written in c. I found a file called octopus_wrap which was created by SWIG!

then I found a makefile which says:

python2.5: swig -python -outdir ./ ../octopus.i gcc -fPIC -c ../../liboctopus/src/octopus.c gcc -fPIC -c ../octopus_wrap.c -I /usr/include/python2.5 gcc -fPIC -shared octopus_wrap.o octopus.o /usr/lib/libusb.so -o _octopus.so

python2.4: swig -python -outdir ./ ../octopus.i gcc -fPIC -c ../../liboctopus/src/octopus.c gcc -fPIC -c ../octopus_wrap.c -I /usr/include/python2.4 gcc -fPIC -shared octopus_wrap.o octopus.o /usr/lib/libusb.so -o _octopus.so

win: gcc -fPIC -c ../../liboctopus/src/octopus.c -I /c/Programme/libusb-win32-device-bin-0.1.10.1/include gcc -fPIC -c octopus_wrap.c -I /c/Python25/libs -lpython25 -I/c/Python25/include -I /c/Programme/libusb-win32-device-bin-0.1.10.1/include gcc -fPIC -shared *.o -o _octopus.pyd -L/c/Python25/libs -lpython25 -lusb -L/c/Programme/libusb-win32-device-bin-0.1.10.1/lib/gcc

clean: rm -f octopus* _octopus*

install_python2.4: cp _octopus.so /usr/local/lib/python2.4/site-packages/ cp octopus.py /usr/local/lib/python2.4/site-packages/

install_python2.5: cp _octopus.so /usr/local/lib/python2.5/site-packages/ cp octopus.py /usr/local/lib/python2.5/site-packages/

I dont know how to handle this but as far as I can see octopus.py and _octopus.so are the resulting output files which are relevant to python right?

luckily someone already did that and so I put those 2 files to my "python26/lib" folder (hope it doesnt matter if it´s python 2.5 or 2.6?!)

So when working with the USB device the octopus.py is the library to work with! Importing this file makes several problems:

>>> 
Traceback (most recent call last):
File "C:\Users\ameise\My Dropbox\µC\AVR\OCTOPUS\octopususb-0.5\demos\python    \blink_status.py", line 8, in <module>
from  octopus import *
File "C:\Python26\lib\octopus.py", line 7, in <module>
import _octopus
ImportError: DLL load failed: module not found.

and here´s the related line 7 :

import _octopus

So there´s a problem considering the .so file! What could be my next step?

I know that´s a lot of confusing stuff but I hope anyone of you could bring some light in my mind!

thy in advance

© Stack Overflow or respective owner

Related posts about python

Related posts about usb