boost-python

Cmake not detecting boost-python when installing ROS

二次信任 提交于 2019-12-06 13:42:09
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 Some (but not all) of the required Boost libraries were found. You may need to install these additional

Boost Python class export fails to compile with linking error in visual studio 2013

 ̄綄美尐妖づ 提交于 2019-12-06 12:10:21
问题 I compiled Boost myself and used it to export the following function to a DLL : #include <boost/python.hpp> using namespace boost::python; std::string greet() { return "hello, dude !!"; } BOOST_PYTHON_MODULE(hello) { def("greet", greet); } This loaded fine in Python after I renamed the hello.dll file to hello.pyd. Now I am trying this : #include <boost/python.hpp> using namespace boost::python; struct World { void set(std::string msg) { this->msg = msg; } std::string greet() { return msg; }

import classes from pyside inside of a boost python module?

心已入冬 提交于 2019-12-06 10:25:15
问题 I'd like to use PySide to define the basic QT classes and the mapping between C++ and python, but to do so in both standalone python code and from embedded python using boost::python. First, the module definition and class returning QPointF: QPointF X::getY() { return QPointF(); } BOOST_PYTHON_MODULE(myBoostPythonModule) { // is there some magic init/register commands to put here? boost::python::api::object module = import("__main__"); boost::python::api::object name_space = module.attr("_

Catch creation of instance attributes of boost::python-wrapped classes from c++

丶灬走出姿态 提交于 2019-12-06 09:43:29
I am wrapping (many) c++ classes with boost::python. If I mistype the attribute name when assigning it from a python script, python silently creates new instance attribute, which is never what I indent. Is there a way to catch such events (and raise exception?)? I've seen a few posts on the web on the topic, but none of them seemd to give a definitive answer; I was trying to override __setattr__ & friends, but I was not able to get it right; plus I was concerned about possible performance impact. Cheers, Vaclav __setattr__ is in fact the way to go. If you're worried about performance, I think

Embedding python and running for multiple times

ぐ巨炮叔叔 提交于 2019-12-06 08:19:11
问题 I'm using boost::python to embed python, this is how I do it: void runCode(){ Py_Initialize(); //boost::python code goes here and embedded python code runs Py_Finalize(); } it runs nicely for the first time, but when it is run again, I get this error: LookupError: unknown encoding: utf8 and code does not run as expected, any help is appreciated. 回答1: Since you didn't get an expert answer, I'm offering my learning from working on a similar problem. Python have issues with reinitialization

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

二次信任 提交于 2019-12-06 06:59:53
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 I will include this module in Python in the long run? Should I do it like: import orm Or will it depend

Force CMake/VisualStudio to use static libs of Boost.Python

半城伤御伤魂 提交于 2019-12-06 05:51:38
问题 I'm currently trying to build on Windows (with Intel compiler) a big project compiling very well on UNIX with CMake. Here is a reduced simple example of my problem. Running the following simple example of code using Boost.Python : #include <iostream> #include <Python.h> #include <boost/python.hpp> int main() { std::string python_home = "C:\\softs\\python\\2.7.9\\64"; char* python_home_char = new char[python_home.length() + 1]; strcpy(python_home_char, python_home.c_str()); Py_SetPythonHome

Bug in Python? threading.Thread.start() does not always return

一个人想着一个人 提交于 2019-12-06 05:22:25
问题 I have a tiny Python script which (in my eyes) makes threading.Thread.start() behave unexpectedly since it does not return immediately. Inside a thread I want to call a method from a boost::python based object which will not return immediately. To do so I wrap the object/method like this: import threading import time import my_boostpython_lib my_cpp_object = my_boostpython_lib.my_cpp_class() def some_fn(): # has to be here - otherwise .start() does not return # time.sleep(1) my_cpp_object.non

Unable to link against Boost.Python on OS X

怎甘沉沦 提交于 2019-12-06 04:39:13
问题 I am trying to build a really trivial example with Boost.Python. I have installed boost and boost-python with homebrew. I am using python 3.4.3 and boost 1.59. My OS is El Capitan. Boost.Python was installed with python3 like this: brew install boost-python --with-python3 I have 3 files: /* greet.hpp */ #ifndef BOOSTPYTHONHELLOWORLD_GREET_HPP #define BOOSTPYTHONHELLOWORLD_GREET_HPP char const* greet(); #endif //BOOSTPYTHONHELLOWORLD_GREET_HPP /* greet.cpp */ #include "greet.hpp" char const*

C++ class not recognized by Python 3 as a module via Boost.Python Embedding

北城以北 提交于 2019-12-06 04:37:27
问题 The following example from Boost.Python v1.56 shows how to embed the Python 3.4.2 interpreter into your own application. Unfortunately that example does not work out of the box on my configuration with MSVC2013 under Windows 8.1. And I have not found 1 working complete example about embedding, at least none that is younger than 10 years or so. I receive the following error running it: ImportError: 'embedded_hello' is not a built-in module The code is here: http://pastebin.com/shTtdxT8 Any