C++ Modules for python: How to?

John Machin sjmachin at lexicon.net
Fri Jul 6 20:39:57 EDT 2007


On Jul 7, 9:26 am, Robert Dailey <rcdai... at gmail.com> wrote:
> On Jul 6, 3:06 pm, "Diez B. Roggisch" <d... at nospam.web.de> wrote:
>
>
>
> > Robert Dailey schrieb:
>
> > > Hi,
>
> > > I'm interested in making a C++ library of mine usable through python.
> > > Python does a similar thing with Expat (the non-validating XML
> > > parser). I notice that with Expat, python is importing a C++ header
> > > file into a PY file and the interface is available to python. I've
> > > read through the python documentation as well as done a little bit of
> > > google research and I've not been able to find a tutorial of some sort
> > > on how to do this. Perhaps I just don't know the right words to search
> > > for.
>
> > > If anyone could lead me in the right direction (possibly an article,
> > > tutorial, etc) I would greatly appreciate it.
>
> > The best thing to do is to offer your C++-lib with a C-style interface.
> > Then you can use python's ctypes (included since python2.5) to access
> > the shared library.
>
> > If you insist on using C++, you can expose the lib using several
> > available wrapper generators. I know of three: SIP, Swig &
> > Boost::Python. The first I've got some very good first-hand experience.
> > The second is somewhat primitive IHMO. The third I never used.
>
> > Use these to google in this group, you'll find plenty of stuff.
>
> > Diez
>
> How do I install SIP? I can't seem to do this. I've downloaded the
> package and read the README file, but I don't see a way of installing
> it on windows. I ran the configure.py file but then it generates
> makefiles to run which can't be run on windows. I also attempted to
> download QT but it doesn't appear to be free (it's an evaluation and I
> don't feel like submitting my personal information to download it).
>
> Am I missing something?

Probably.

"makefiles ... which can't be run on windows"??? Have you acquired a
make program [if necessary] and tried it? What happened?

The free Borland compiler comes with a make.exe. If you plan to use
GCC, you will probably need this:
    http://gnuwin32.sourceforge.net/packages/make.htm
I understand that if you have a Microsoft compiler, you should have an
nmake.exe.

If all else fails, e-mail the package author, supplying some relevant
information, like what compiler you are using, what options you used
on the configure.py run, which "make" you are using, what happened
when you ran that make, ...





More information about the Python-list mailing list