boost-python

Boost autolinks libraries which are not build by Boost, but the intented once are build.

Hello, I am developing a Math application which can be extended by writing python scripts. I am using QT 4.6.3 (build as static library, debug and release versions) and Boost 1.43.0 (build as static library, runtime-link also set to static, multi-threaded version, debug and release). Everything is build with MSVC++2008. The boost build ...

Inter-module exception name resolution through boost python does not work?

Here is my problem: I have two C++ modules, A and B, which are built as dynamically-linked libraries. A offers basic math functions, and custom exception types. B is a higher level module that uses A. B::someFunction() calls a function from A, and tries to catch custom exception A:MyExceptionFromA in order to convert it into a custom t...

How does python load Boost.Python libraries?

Considering the following archetypal Boost.Python module, which brings a class "D" from a separate C++ header file. /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c) { class_<d>("D") } When I compile this to a shared library, I'm confused how I can expose it to Python. What should I call the library? a.so? liba.so? b.so? libb.so? Where...

Boost.Python function pointers as class constructor argument

I have a C++ class that requires a function pointer in it's constructor (float(*myfunction)(vector<float>*)) I've already exposed some function pointers to Python. The ideal way to use this class is something like this: import mymodule mymodule.some_class(mymodule.some_function) So I tell Boost about this class like so: class_<Some...

Registering python callables in C++ classes

I'm writing a program in python which should be able to pass "callables" which are registered in a C++ class. So far I've written the following code: C++: class MyClass { ... public: register_callback(boost::function<void (int)> fun); }; Python/C API: class_<MyClass, boost::shared_ptr<MyClass>, boost::noncopyable>("MyClass", no_...

How does Boost.Python work?

How is Python able to call C++ objects when the interpreter is C and has been built w/ a C compiler? ...

Boost.Python method returned strings truncated, unexpected integer values

I'm using Boost.Python to expose JRA's BWRepLib so I can try to do some data mining on sc:bw replays in python and I've run into a small problem with the values being returned from the C++ methods. When running any old simple program such as the tutorial I get the expected value returned to python (a "hello, world" string that prints out...

Building Python libraries on a Mac and experiencing flat namespace errors

As a general rule, I rue the days whenever I have to build Python libraries on a Mac. I've generally had fairly good success using Boost::Python, and if I use distutils, most of the time everything works correctly. However, I've never been able figure out the exact combination of what works/what doesn't work. Specifically, I've often ru...

How to prevent boost::python::extract<float> from accepting int

I'm using boost::python::extract<> to convert the items in a boost::python::list to floats. My problem is with int's in python - extract<float> seems to regard int->float as a valid conversion, however I only want true float objects. Is there a way to force extract<> to be more conservative? extract<float> value(o); if (value.check()) {...

Using boost.python with make instead of bjam

Hi folks, I'm just trying to compile the "hello world" example of boost.python WITHOUT using all the bjam magic. My boost.python installation is working, I did succesfully build the example with bjam and passed the test suite. Now for my project I need to use all this stuff in a plain Make environment. I don't want to port to another b...

boost::python: howto call a function that expects a pointer?

Hi all, I have a function that takes an int-pointer and exposed it via boost::python. How can I call this function from python? in C++ with boost::python: void foo(int* i); ... def("foo", foo); in python: import foo_ext i = 12 foo_ext.foo(i) results in Traceback (most recent call last): File "<stdin>", line 1, in <module> Boos...

Python to C++ function conversion using Boost.Python

Hi, I have a bunch of classes and APIs written in C++ and exposed to Python with help of Boost.Python I am currently investigating the possibilities of creating the following architecture. In python: from boostPythonModule import * AddFunction( boostPythonObject.Method1, args ) AddFunction( boostPythonObject.Method2, args ) AddFuncti...

How can I extend an embedded python interpreter with C++ functions?

How can I extend an embedded interpreter with C++ code? I have embedded the interpreter and I can use boost.python to make a loadable module (as in a shared library) but I don't want the library floating around because I want to directly interface with my C++ application. Sorry if my writing is a bit incoherent. ...

Debug a module built with Boost.Python in QtCreator

I have a module built with Boost.Python and I want to debug it in QtCreator (or perhaps gdb). I prefer a visual environment if possible. ...

How do I pass/catch/respond to Python's KeyboardInterrupt in C++?

I have a simple library written in C++ which I'm creating a Python wrapper for using boost.python. Some functions take a long time to execute (over 30 seconds), and I would like to make it interruptible so that when I hit ctrl-d to trigger KeyboardInterrupt in the python interpreter, I'm somehow able to respond to that in C++. Is there ...

Build Boost and Exempi on a Mac

In order to install Python XMP Toolkit, I need to install Exempi on my Mac, but doing this is becoming a real nightmare... After a lot of trouble, i finally made it with boost, and had the fantastic The Boost C++ Libraries were successfully built! The following directory should be added to compiler include paths: /usr/loc...