boost-python

Boost Python and Cmake with Ubuntu and Python3.5

我是研究僧i 提交于 2019-12-22 09:17:16
问题 I'm having issues getting Boost Python to compile with Cmake. Everything works fine when compiled manually. Here is how I set everything up and ran it : Install python 3.5 : sudo apt-get install python3-dev Download the lastest version of Boost from http://www.boost.org/ Run bootstrap with correct flags : ./bootstrap.sh --with-python=python3.5 Compile Boost in directory : ./b2 Install Boost headers to /usr/local/include and Boost libs to /usr/lib/x86_64-linux-gnu sudo ./b2 install Compile

boost.python: Argument types did not match C++ signature

别来无恙 提交于 2019-12-22 05:58:21
问题 I am having a strange problem when calling a C++ function in python. I exposed a class from which I want to call a function: class_<MyClass, std::shared_ptr<MyClass>>("MyClass", init<>()) // ... .def("someFunc", &MyClass::someFunc) ; I get a std::shared_ptr<MyClass> from a member variable from another class which is exposed via .def_readonly(...) When I try to call the function, I get the following error: File "pytest.py", line 27, in test_func cu.someFunc("string") Boost.Python.ArgumentError

why do I need comparison operators in boost python vector indexing suite?

时光怂恿深爱的人放手 提交于 2019-12-22 05:23:31
问题 I would like to expose C++ code with a std::vector<A> to python. My class A{}; does not have a comparison operator implemented. When I try BOOST_PYTHON_MODULE(libmyvec) { using namespace boost::python; class_<A>("A"); class_<std::vector<A> >("Avec") .def(boost::python::vector_indexing_suite<std::vector<A> >()); } I get an error about comparison operators. If I change the definition of A to class A { public: bool operator==(const A& other) {return false;} bool operator!=(const A& other)

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

纵然是瞬间 提交于 2019-12-22 05:04:10
问题 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 code wise, but they are different in implementation. I am writing wrappers around each language's apis. Each wrapper should expose the exact same functionality

How to expose a c++ function taking variable arguments in boost python

偶尔善良 提交于 2019-12-22 01:29:07
问题 I have a c++ function taking variable number of arguments. char const* Fun(int num, ...) { ....//does some processing on the arguments passed } Boost Python code for exposing this function is written as, using namespace boost::python; BOOST_PYTHON_MODULE( lib_boost ) { def( "Fun", Fun ); } while compiling this code gives the below error In file included from /boost_1_42_0/boost/python/data_members.hpp:15, from /boost_1_42_0/boost/python/class.hpp:17, from /boost_1_42_0/boost/python.hpp:18,

Pickling an enum exposed by Boost.Python

时光毁灭记忆、已成空白 提交于 2019-12-21 17:01:39
问题 Is it possible to pickle (using cPickle) an enum that has been exposed with Boost.Python? I have successfully pickled other objects using the first method described here, but none of that seems to apply for an enum type, and the objects don't seem to be pickleable by default. 回答1: Not as they are in the module. I am given to understand that this is SUPPOSED to be possible, but the way the enum_ statement works prevents this. You can work around this on the python side. Somewhere (probably in

what is wrong with c++ streams when using boost.python?

泄露秘密 提交于 2019-12-21 07:13:25
问题 Update 2: I'm not sure why this is still being upvoted (March 2014). This appears to be fixed since I asked this question many years ago. Make sure you're using a recent version of boost. UPDATE: Perhaps C++ streams need to be initialized in order to format numbers, and the initialization is not happening when the shared library is loaded in Python? I am calling cout << 1 << "!" << endl; in a method that is exported to a shared library via boost.python. It doesn't print anything, but if I do

Boost Python No to_python converter found for std::string

ε祈祈猫儿з 提交于 2019-12-21 07:01:59
问题 So, I am trying to create a to_python converter that will allow me to return a boost::optional from an exposed function and have it treated as T if the optional is set and None if not. Based on a post I found on C++Sig, I wrote the following code. template<typename T> struct optional_ : private boost::noncopyable { struct conversion { static PyObject* convert(boost::optional<T> const& value) { if (value) { return boost::python::to_python_value<T>()(*value); } Py_INCREF(Py_None); return Py

Unable to import a custom DLL in python

依然范特西╮ 提交于 2019-12-21 06:19:10
问题 I am trying to expose a C++ class to python with boost::python , so I am going through this tutorial. I created a visual studio .dll project, with this source code: #include <boost/python.hpp> using namespace boost::python; struct World { void set(std::string msg) { this->msg = msg; } std::string greet() { return msg; } std::string msg; }; BOOST_PYTHON_MODULE(hello) { class_<World>("World") .def("greet", &World::greet) .def("set", &World::set) ; } And I built it as a 64-bit dll. The next step

Boost autolinks libraries which are not built by Boost, but the intended ones are built

断了今生、忘了曾经 提交于 2019-12-20 02:15:46
问题 I am developing a Math application which can be extended by writing python scripts. I am using Qt 4.6.3 (built as static library, debug and release versions) and Boost 1.43.0 (built as static library, runtime-link also set to static, multi-threaded version, debug and release). Everything is built with MSVC++2008. Boost built the following libraries: libboost_python-vc90-mt-s-1_43.lib libboost_python-vc90-mt-s.lib libboost_python-vc90-mt-sgd-1_43.lib libboost_python-vc90-mt-sgd.lib My project