boost-python

Are CPython, IronPython, Jython scripts compatible with each other?

I am pretty sure that python scripts will work in all three, but I want to make sure. I have read here and there about editors that can write CPython, Jython, IronPython and I am hoping that I am looking to much into the distinction. My situation is I have 3 different api's that I want to test. Each api performs the same functionality...

How to build a boost dependent project using regular makefiles?

I'm working on a c++ project, and we recently needed to include a small part of boost in it. The boost part is really minimal (Boost::Python), thus, using bjam to build everything looks like an overkill (besides, everyone working on the project feels comfortable with make, and has no knowloedge of jam). I made quite some tests already, ...

building boost python examples using Visual Studio 2008

I'm using Boost Python library to create python extensions to my C++ code. I'd like to be able to invoke from python the 'greet' function from the C++ code shown below: #include <boost/python/module.hpp> #include <boost/python/def.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespa...

Boost.python failed with libboost_python.so.1.41.0: cannot open shared object file

Hi, I have already installed Boost.Python. There were no erros during instalation, but I have a problem. When I try to build my project ererything is OK, but when I run my wrapped project there is an error: import wrraped_project ImportError: libboost_python.so.1.41.0: cannot open shared object file: No such file or directory I tried ...

Selecting An Embedded Language

I'm making an application that analyses one or more series of data using several different algorithms (agents). I came to the idea that each of these agents could be implemented as separate Python scripts which I run using either the Python C API or Boost.Python in my app. I'm a little worried about runtime overhead TBH, as I'm doing so...

How to write a wrapper over functions and member functions that executes some code before and after the wrapped function?

I'm trying to write some wrapper class or function that allows me to execute some code before and after the wrapped function. float foo(int x, float y) { return x * y; } BOOST_PYTHON_MODULE(test) { boost::python::def("foo", <somehow wrap "&foo">); } Ideally, the wrapper should be generic, working for functions and member fun...

Python method to boost function

I have a method exported to Python using boost python that takes a boost::function as an argument. From what I have read boost::python should support boost::function without much fuss, but when I try to call the function with a python method it gives me this error Boost.Python.ArgumentError: Python argument types in Class.createTim...

Boost::Python: Passing custom arguments to gcc when building python-extension

I need to pass -Wl,-rpath,\$$ORIGIN/lib/ to g++'s linker (reason). Is there a way to pass this argument in Jamroot file? ...

How to use C++ operators within python using boost::python (pyopencv)

I'm using the pyopencv bindings. This python lib uses boost::python to connect to OopenCV. Now I'm trying to use the SURF class but don't know how to handle the class operator in my python code. The C++ class is defined as: void SURF::operator()(const Mat& img, const Mat& mask, vector<KeyPoint>& keypoints) const {...}...

boost::python Export Custom Exception

I am currently writing a C++ extension for Python using Boost::Python. A function in this extension may generate an exception containing information about the error (beyond just a human-readable string describing what happened). I was hoping I could export this exception to Python so I could catch it and do something with the extra inf...

Unwind a function call

This is a difficult problem to describe so please let me know if anything is unclear. I am trying to solve a possible deadlock situation in my C++ app and I am having trouble visualizing an appropriate solution. The restrictions placed on me by the two libraries I am trying to connect make my problem very complex and troublesome but it...

Wrapping a pure virtual method with arguments using Boost::Python.

I'm currently trying to expose a c++ Interface (pure virtual class) to Python using Boost::Python. The c++ interface is: Agent.hpp #include "Tab.hpp" class Agent { virtual void start(const Tab& t) = 0; virtual void stop() = 0; }; And, by reading the "official" tutorial, I managed to write and build the next Python wrapper: A...

How can I use Boost::Python to add a method to an exported class without modifying the base class?

I have a class in C++ that I can't modify. However, that class holds an std::list<> of items that I need to be able to access in a Python extension. Since Boost::Python doesn't seem to have a built-in conversion between an std::list and a Python list, I was hoping to be able to write a method in C++ that could do this conversion for me...

C++ iostreams and python

Is it possible to interoperate with a C++ iostream and python? I'm using boost-python and want to wrap a function that has istream and ostream as arguments. ...

resolving overloads in boost.python

I have a C++ class like this: class ConnectionBase { public: ConnectionBase(); template <class T> Publish(const T&); private: virtual void OnEvent(const Overload_a&) {} virtual void OnEvent(const Overload_b&) {} }; My templates & overloads are a known fixed set of types at compile time. The application code derives f...

Pass by reference in Boost::Python

Hi everybody. Consider something like: struct Parameter { int a; Parameter(){a = 0;} void setA(int newA){a = newA;} }; struct MyClass { void changeParameter(Parameter &p){ p.setA(-1);} }; Well, let's fast forward, and imagine I already wrapped those classes, exposing everything to python, and imagine also I instantiate...

Using boost.python to import a method with opencv calls but failing due to symbols not being found after compilation

So I don't have the code right now, as I am not home... but i used the boost library for python in C++ to allow python to access a function called something like loadImageIntoMainWindow(string filepath) in the C++ source code the method calls opencv methods that are imported at the top of the file, I included opencv in my Jamroot file, ...

Exposing a pointer in Boost.Python

I have this very simple C++ class: class Tree { public: Node *head; }; BOOST_PYTHON_MODULE(myModule) { class_<Tree>("Tree") .def_readwrite("head",&Tree::head) ; } I want to access the head variable from Python, but the message I see is: No to_python (by-value) converter found for C++ type: Node* From w...

Exposing boost::scoped_ptr in boost::python

Hello, I am getting a compile error, saying that the copy constructor of the scoped_ptr is private with the following code snippet: class a {}; struct s { boost::scoped_ptr<a> p; }; BOOST_PYTHON_MODULE( module ) { class_<s>( "s" ); } This example works with a shared_ptr though. It would be nice, if anyone knows the answer. Thank...

Adding python script to c++ project

How would I go about adding a script written in python to a c++ project? Thanks Edit: Basically all the script does is email some data. I would like to pass the data and maybe the email address to a function written in python. Hope that clears things up.. ...