[C++-sig] my experiences with boost/python so far

David Abrahams david.abrahams at rcn.com
Wed Apr 10 19:38:50 CEST 2002


----- Original Message -----
From: "Robert Andre" <randre at pppl.gov>


>
> I am relatively new to the boost/python library so I thought I would
relate
> some of my experiences with using boost on a dual processor,
> linux mandrake 8.0, 2.2 kernel with gcc 3.0.4:
>
> 1) building requires a magic command.  I probably missed the
documentation somewhere

Probably not; we're running behind in that department.

>    but my magic command turned out to be
>
>





jam -sBOOST_ROOT=/home/randre/cvs/boost -sTOOLS="gcc" -sPYTHON_ROOT="/us
r/local" \
>          -sPYTHON_VERSION=2.2 -sPYTHON_LIB_PATH="/usr/local/lib/python
2.2"
>
>    If I leave off the PYTHON_LIB_PATH I get the failure,
>
> Couldn't find Python 2.2 installation in /usr/local
> skipping Boost.Python library build
> You can configure the location of your python installation, by
setting:
> PYTHON_ROOT - currently "/usr/local"
> PYTHON_VERSION - currently "2.2"
> PYTHON_INCLUDES - configured from PYTHON_ROOT, currently
"/usr/local/include/python2.2"
> PYTHON_LIB_PATH - configured from PYTHON_ROOT, currently
"/usr/local/lib/python2.2/config"
> ...found 402 targets...

Hmm. I may have to have another look at the defaults. Thanks for
reporting this.

>    To test, I had to add -sGCC_ROOT_DIRECTORY=/usr/local with the
target 'test' because
>    I use LD_LIBRARY_PATH (I know I shouldn't)

Why not?

>    and it gets reset by the test.

Hmm, it is supposed to get *extended* by the test.

>    The pickle
>    tests always seem to fail for me.
>
>    Is there a way to see what  gcc-C++-action  and  gcc-Link-action
are doing?

Yes, add -d+2 to your command-line, before the first target.

> 2) I've had no luck in compiling boost on any system with gcc 2.9*
because of the
>    template instantiation support -- so much for Mac OS X.

Weird; it's working for me with MinGW 2.95.3
I just checked in some changes last night which should make that
healthier, though. Please try again at your convenience.

> 3) creating a single module worked fine but when I started using two
modules built
>    with boost I would get seg faults deep within stringstream --
something to do with a
>    missing character_trait used in double conversions.  I'm guessing a
compiler bug or
>    I built my gcc incorrectly. I finally had to force the use of the
deprecated
>    strstream in  operators.hpp.

This one doesn't sound like it has anything to do with Boost.Python.

> 4) I created an exception class derived from std::exception.
Generally this works but
>    sometimes the exception type gets lost somehow and I end up with
the python
>    message 'RuntimeError: unidentifiable C++ exception' instead of my
nice error
>    message.  Exceptions were very unstable until I compiled gcc with
the
>    --enable-sjlj-exceptions option.

Exception support in GCCs prior to 3.0.1 was notoriously erratic.

> 5) The function overloading and cross module support are really really
cool.
>
> 6) I'm not totally sure of what I am doing when I make to_python() and
from_python()
>    functions.  The reference class looks good but I have to study it
to
>    figure out what is going on with the reference counting.  The
to_python(PyObject*)
>    does not transfer ownership the way I thought it would for ordinary
functions so I
>    ended up wrapping a PyObject* in my own TransferPyObject class with
a
>    to_python(TransferPyObject) which transfers ownership.  There's
probably a better way.

Boost.Python v2 will be smoother ;-)

> 7) Overall I am very impressed with the ease of building a C++
extension but I am never
>    quite sure what will happen when I run the extensions and I haven't
stressed tested
>    them.  I'm hoping gcc 3.1 solves some of my issues because solid
linux support is
>    required for what I am doing.  Are there any other compilers for
linux which work with
>    boost/python or do other gcc users not have these problems?   I've
got a few other
>    unix architectures which I will eventually test it on.

Ralf has been using v1 on a bunch of different Unices. We've been
testing v2 on Linux and OSF with GCC, KCC, and Compaq Tru64 CXX (several
versions).

Thanks for using Boost.Python!

-Dave






More information about the Cplusplus-sig mailing list