boost-python

How to send signal using callback called from external script?

ぐ巨炮叔叔 提交于 2019-12-08 05:10:00
问题 Introduction I'm trying to update QT GUI element basing on the state of calculations in embedded python script. I'm able to extract required values from python, but can't set a reference to c++ object to make it work. The details Let's assume python code is called (in calc.cpp) this way: void class_name::transfer(varA, varB, varC) { Py_Initialize(); emit inprogress(70); //HERE IT WORKS object module = import("__main__"); object name_space = module.attr("__dict__"); exec_file("MyModule.py",

Pass C++ object contained in a smart pointer to Python

元气小坏坏 提交于 2019-12-08 02:45:14
问题 I have a class in C++. I create an object from this class in my C++ code. I want this object to be accessible in Python. I use boost::shared_ptr to keep the object address. I've checked out some posts about this but wasn't very helpful. I think the best way is to make an object in Python namespace after interpreter initialization and then assign my boost shared_ptr to the created object in Python. I've wrapped my class using BOOST_PYTHON_MODULE in cpp and tested some ways like namespace["my

How to compile, create shared library, and import c++ boost module in Python

依然范特西╮ 提交于 2019-12-08 02:41:23
问题 I see there are tons of information on the Web about how to compile c++ modules for Python. But the problem is, practically any programmer has his own way of compiling and his own list of flags and another tricks. So, taking into account such a variety of tricks, I can't decide which method I should use and besides I have some other questions. This is what I tried: // part of main.cpp file .... BOOST_PYTHON_MODULE( orm ){ class_<ORM>( "ORM", // other code goes here } My first question is how

Cmake not detecting boost-python when installing ROS

孤者浪人 提交于 2019-12-07 19:53:30
问题 I have been trying to install ROS on my Mac and have gotten around the errors with different libraries depending on different versions of boost. However, it seems that one library is not even detecting boost-python. Here is the error I get: CMake Error at /usr/local/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message): Unable to find the requested Boost libraries. Boost version: 1.67.0 Boost include path: /usr/local/include Could not find the following static Boost libraries: boost_python

Boost.Python: Ownership of pointer variables

情到浓时终转凉″ 提交于 2019-12-07 16:44:24
问题 I'm exposing a C++ tree class using Boost.Python to python. The node class holds a list of child nodes and provides a method void add_child(Node *node) The Node class takes ownership of the provided Node pointer and deletes it's child nodes when the destuctor gets called. I'm exposing the add_child method as: .def("addChild", &Node::add_child) My actual question is: How do i tell Boost.Python that the Node class takes ownership of the child nodes? Because if i execute the following code in

How to organise python / Boost Python projects

隐身守侯 提交于 2019-12-07 12:19:50
问题 I have a python project, to which I would like to interface with some C++ libraries using Boost::Python. I would like to know how others go about organising their python/boost::python/C++ code within the same project. By organisation I mean in terms of file/directory structure, build procedures etc. 回答1: In what follows, pif denotes Python InterFace. First I've got a generic header file, called conv_pif.hpp, which has Boost headers and C++ Std Library headers and such. Then for each boost

Explain Python extensions multithreading

痴心易碎 提交于 2019-12-07 11:12:51
问题 Python interpreter has a Global Interpreter Lock, and it is my understanding that extensions must acquire it in a multi-threaded environment. But Boost.Python HOWTO page says the extension function must release the GIL and reacquire it on exit. I want to resist temptation to guess here, so I would like to know what should be GIL locking patterns in the following scenarios: Extension is called from python (presumably running in a python thread). And extension's background thread calls back

manually building a python extension in cygwin with boost.python

巧了我就是萌 提交于 2019-12-07 07:46:16
问题 Sorry for such a general title, but i'm not quite sure what exactly i'm missing or what i'm doing wrong. My aim is to build a python extension using boost.python under cygwin and avoiding boost.build tools, that is using make instead of bjam. The latter way was working for me quite good, but now i want to do it this way. I solved many issues by googling and looking for similar topics and that helped me to figure out some tricks and to move forward. Yet at the last step there seems to be some

Building a Boost.Python application on MacOS 10.9 (Mavericks)

吃可爱长大的小学妹 提交于 2019-12-07 06:43:20
问题 I upgraded to Mavericks, and am now unable to build my application after much troubleshooting. During linking, I receive the errors Undefined symbols for architecture x86_64: "boost::python::objects::function_object(boost::python::objects::py_function const&, std::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&) . . . "boost::python::objects::register_dynamic_id_aux(boost::python::type_info, std::pair<void*, boost::python::type_info> (*)(void*))" I am

Performance of Boost Python

百般思念 提交于 2019-12-07 05:36:07
问题 I working on a project where I'm experimenting with boost python. When looking into how to organize my python interface I ran into a comment that asserted there are performance concerns with boost python. Is there any actual concern with it's performance? In this case I'm working with a large project and we want to expose some of it to python. I'm finding that boost python makes it easy to expose the classes I already have. So I would prefer to stick with boost python's methods of exposing