[PyQt] Basic SIP

Mico Siahaan mico.siahaan at gmail.com
Thu Sep 16 09:50:16 BST 2010


Dear all,

I am learning SIP and I made simple source like this:

//spam.cpp

#include "spam.h"

int spam_system(const char *command);

int main(int argc, char **argv )
{
spam_system(argv[1]);
return 0;
}

int spam_system(const char *command)
{
int sts;
sts = system(command);
return sts;
}


spam.h is in the same folder of spam.cpp and containing:

// spam.h
#include <cstdlib>

int spam_system(const char *command);


Then I made simple setup.py:

from distutils.core import setup, Extension
import sipdistutils

setup(
  name = 'spam',
  version ='0.1',
  ext_modules = [
    Extension("spam", ["spam.sip", "spam.cpp"])
    ],
  cmdclass = {'build_ext': sipdistutils.build_ext}
 )

with spam.sip:

/* Define the SIP wrapper to the spam library. */

%Module spam 0

%ModuleHeaderCode
#include "spam.h"
%End

int spam_system(const char *command);


Then run 'python.exe setup.py build'. But then I got error messages

spam.sip(6) : fatal error C1083: Cannot open include file: 'spam.h': No such
file or directory
error: command '"C:\Program Files\Microsoft Visual Studio
9.0\VC\BIN\cl.exe"' failed with exit status 2

My question: where shall I put spam.h then so sip can compile it
successfully? How is the best structure of building python binding with sip?
And sorry for the long email.

-- 
Mico | mico.siahaan at gmail.com | @bangmico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100916/a86dd177/attachment.html>


More information about the PyQt mailing list