boost-python

Boost.Python function pointers as class constructor argument

≡放荡痞女 提交于 2020-01-02 21:58:16
问题 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_<SomeClass>("some_class", init<float(*)(vector<float>*)>); But I get: error: no matching function for call to 'register_shared_ptr1(Sample (*)(std::vector<double, std:

Boost.Python function pointers as class constructor argument

こ雲淡風輕ζ 提交于 2020-01-02 21:58:00
问题 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_<SomeClass>("some_class", init<float(*)(vector<float>*)>); But I get: error: no matching function for call to 'register_shared_ptr1(Sample (*)(std::vector<double, std:

Converting python.io object to std::istream when using boost::python

我只是一个虾纸丫 提交于 2020-01-02 06:55:29
问题 While writing my first django application I've faced the following problem with boost::python . From python code, I need to pass io.BytesIO to the C++ class which takes std::istream . I have a legacy C++ library for reading files of certain format. Let's call is somelib . The interface of this library uses std::istream as an input. Something like this: class SomeReader { public: bool read_from_stream(std::istream&); }; And I want to wrap it, so that I can use my lib from python in the

Python, Threads, the GIL, and C++

不打扰是莪最后的温柔 提交于 2020-01-01 18:24:30
问题 Is there some way to make boost::python control the Python GIL for every interaction with python? I am writing a project with boost::python. I am trying to write a C++ wrapper for an external library, and control the C++ library with python scripts. I cannot change the external library, only my wrapper program. (I am writing a functional testing application for said external library) The external library is written in C and uses function pointers and callbacks to do a lot of heavy lifting.

Configuring Visual Studio to work with Boost.Python and Python 3

Deadly 提交于 2019-12-31 03:07:08
问题 I had Microsoft Visual Studio Community 2013 (Version 12.0.31101.00 Update 4) and Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017) on my PC with Windows 10 Pro. In order to try examples with Boost.Python I downloaded boost 1.64.0 and build libraries by b2 with options --with-python --toolset=msvc --build-type=complete . As a result I have the following files: boost_python3-vc120-mt-1_64.dll boost_python3-vc120-mt-1_64.lib boost_python3-vc120-mt-gd-1_64.dll boost_python3-vc120-mt-gd-1_64.lib

Undefined boost python symbol: boost::python::detail::init_module

孤人 提交于 2019-12-31 01:52:33
问题 I get an undefined symbol error when trying to import an extension compiled with boost python, and the symbol is one that should be included in the boost library. I am using Boost 1.46.1, Python 3.1.2, and GCC 4.4.5. I've built boost using: $ ./bootstrap.sh --with-python-version=3.1 $ sudo ./bjam -j4 install I then compiled the following trivial Boost Python library: #include <boost/python.hpp> struct mystruct { int i; }; BOOST_PYTHON_MODULE(test) { using namespace boost::python; class_

Undefined boost python symbol: boost::python::detail::init_module

白昼怎懂夜的黑 提交于 2019-12-31 01:52:00
问题 I get an undefined symbol error when trying to import an extension compiled with boost python, and the symbol is one that should be included in the boost library. I am using Boost 1.46.1, Python 3.1.2, and GCC 4.4.5. I've built boost using: $ ./bootstrap.sh --with-python-version=3.1 $ sudo ./bjam -j4 install I then compiled the following trivial Boost Python library: #include <boost/python.hpp> struct mystruct { int i; }; BOOST_PYTHON_MODULE(test) { using namespace boost::python; class_

How to get Python exception text

☆樱花仙子☆ 提交于 2019-12-28 08:09:22
问题 I want to embed python in my C++ application. I'm using Boost library - great tool. But i have one problem. If python function throws an exception, i want to catch it and print error in my application or get some detailed information like line number in python script that caused error. How can i do it? I can't find any functions to get detailed exception information in Python API or Boost. try { module=import("MyModule"); //this line will throw excetion if MyModule contains an error } catch (

Runtime error R6034 in embedded Python application

南楼画角 提交于 2019-12-28 07:58:32
问题 I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated "scripts" which interact with the main program. Unfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded. I am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with

compilation error whith boost-python and lapack

[亡魂溺海] 提交于 2019-12-25 07:27:18
问题 I created a program using boost for extracting python variables and lapack for solving matrix. However I have some trouble in compilation process Here are my includes and the firsts line of code : #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include "lapacke.h" #include <math.h> #include <omp.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <stdarg.h> #include <math.h> #include <sys/times.h> #include <exception> #include <fstream> #include <iostream> #include