From: omnia neo on
Hi All,

I was looking at the SIP tool to create a C extensions for python to
call.
Here is what I tried:
1. I created a simple c file and .h file <attached testfunc.c and
testfunc.h>
2. Then I created a corresponding testfunc.sip file
###################
%CModule siptest 0

%UnitCode
#include"testfunc.h"
%End

void pyfunc();
%MethodCode
func1();
%End
####################

3. I ran SIP <command: sip -e -j 1 -c . testfunc.sip> on this which
generated the following files:
sipsiptestpart0.c and sipAPIsiptest.h
4. I then added these generated files along with testfunc.c and
testfunc.h in my MS Visual studios solution to create a testsip.dll
file
5. Now to call my module from this dll I invoke a script which tries
to import my modules. My pythn call is as follows:

#code#
import siptest

I get following error :
import error : no module named siptest

Please help me find what I am not doing or what mistake am i commiting.
From: Stefan Behnel on
omnia neo, 09.04.2010 07:01:
> import siptest
>
> I get following error :
> import error : no module named siptest

Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)?

Otherwise, Python can't find it.

Stefan

From: omnia neo on
On Apr 9, 10:30 am, Stefan Behnel <stefan...(a)behnel.de> wrote:
> omnia neo, 09.04.2010 07:01:
>
> > import siptest
>
> > I get following error :
> > import error : no module named siptest
>
> Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)?
>
> Otherwise, Python can't find it.
>
> Stefan

thanks for reply Stefan..
well I added PYTHONPATH = <my dll path> in my environment variables
(windows XP).
From: omnia neo on
On Apr 9, 10:42 am, omnia neo <neo.omn...(a)gmail.com> wrote:
> On Apr 9, 10:30 am, Stefan Behnel <stefan...(a)behnel.de> wrote:
>
> > omnia neo, 09.04.2010 07:01:
>
> > > import siptest
>
> > > I get following error :
> > > import error : no module named siptest
>
> > Is the directory where your siptest.dll lies in your PYTHONPATH (sys.path)?
>
> > Otherwise, Python can't find it.
>
> > Stefan
>
> thanks for reply Stefan..
> well I added PYTHONPATH = <my dll path> in my environment variables
> (windows XP).

well I just tried this too.
I added the path using sys.path on the fly in my python script as
follows:

###############
import sys
sys.path.append("<dll path>")
print sys.path
import siptest
###############

again same error:
ImportError: No module named siptest.
From: Gabriel Genellina on
omnia neo <neo.omnia7 <at> gmail.com> writes:
> On Apr 9, 10:42 am, omnia neo <neo.omn...(a)gmail.com> wrote:
> > On Apr 9, 10:30 am, Stefan Behnel <stefan...(a)behnel.de> wrote:
> >
> > > omnia neo, 09.04.2010 07:01:
> >
> > > > import siptest
> >
> > > > I get following error :
> > > > import error : no module named siptest
> >
> > > Is the directory where your siptest.dll lies in your PYTHONPATH
(sys.path)?
> > well I added PYTHONPATH = <my dll path> in my environment variables
> > (windows XP).
>
> well I just tried this too.
> I added the path using sys.path on the fly in my python script as
> follows:
>
> ###############
> import sys
> sys.path.append("<dll path>")
> print sys.path
> import siptest
> ###############
>
> again same error:
> ImportError: No module named siptest.

Make sure the extension module must is called siptest.pyd, not siptest.dll
http://docs.python.org/extending/windows.html
(I'd expect SIP to take care of this)

--
Gabriel Genellina