1,349 questions
0
votes
0
answers
56
views
How is the rvalue_from_python_stage1_data convertible pointer is deallocated in boost python
Question
Can you provide some insight what is the role of the rvalue_from_python_stage1_data convertible pointer and how is being deallocated (memory managed) in boost python?
Background
According to ...
2
votes
1
answer
56
views
boost::python pointer to Base class extraction fail
I created a program that exposes class with virtual function to python using boost::python. Also I configured everything so that I could load python module that was created by boost::python and ...
2
votes
0
answers
45
views
boost::python - Export Custom Exception (2nd edition)
Based on Boost 1.88.0, boost::python Export Custom Exception and linked discussions I'm using the following to expose a custom C++ std::exception to python.
class cException : public std::exception
{
...
0
votes
1
answer
87
views
How to avoid defining a wrapper for abstract base class if I only expose derived classes to python but still use the base class non virtual methods?
Given this class
class ABC {
const std::string& getid() const;
/// other pure virtual methods
};
class D1 : public ABC {
/// override and implement virtual methods
};
class D2 : public ...
0
votes
0
answers
52
views
boost:python expose const std::string& [duplicate]
I understand std::string is exposed to python by implicit converters that don't need to be registered.
However, const std::string& isn't
I have
class Cal {
const std::string& get_name() ...
0
votes
0
answers
86
views
Allocating Mutex in a Python Module Developed with C++
I want to create a C++ library that will support both C++-based and Python-based applications running on Windows 10. The C++ application is multi-threaded, so I protect critical sections in my library ...
0
votes
0
answers
56
views
How to make boost::python use the Python embeddable package
I'm currently working on a 32-bit C++ DLL in Visual Studio 2022 which uses boost::python to embed Python code. For my builds I use the include and lib directories from a full installation of 32-bit ...
1
vote
1
answer
104
views
How do I initialize python when running a program as a service in Windows?
I am creating a service based on SFL (Service Framework Library). When I work from the console, it is okay, but when I run it as a service, via "sc start MyService", it issues fatal errors ...
0
votes
0
answers
86
views
Using the Boost library to include a C++ program in python with Python.h, bjam not found
I have code in C++ that performs multiple mathematical equations. When doing it with Python, it takes a long time (about 5 minutes), and when running it in C++, it takes about 10 seconds. I want to ...
0
votes
0
answers
51
views
CMake target_link_libraries for boost-python is the variable ${PYTHON_LIBRARIES} needed?
I am following Advanced C++ / Python integration with Boost.Python tutorial to get a get a grasp on Boost-Python lib.
In the example above I have:
hello.cpp :
#include <boost/python.hpp>
#...
1
vote
1
answer
75
views
Use Boost python with libtorch
I am trying to create a python package from C++ code with Boost python. However when including libtorchin the code, the resulting python package shows strange errors such as
Boost.Python....
1
vote
0
answers
44
views
Pass std::map to python as a parameter [duplicate]
I have the following C++ code:
const std::string Get(const std::map<std::string, std::string> map) {
PyObject* module = PyImport_ImportModule("dummy");
boost::python::dict ...
1
vote
1
answer
69
views
Beast Socket from Boost Python Package Kills Jupyter Kernel
For some reason when exposing the below to python using Boost Python, the unique pointer constructor (the obj constructor) fails. This used to work for me before, not sure why it stopped.
#pragma once
...
0
votes
0
answers
86
views
Visual Studio 2022 not creating DLL using Boost.Python
After following this page on how to install boost in Visual Studio 2022, I added the hello world for Boost.Python into the main.cpp file. However, even though the program builds and runs successfully, ...
0
votes
0
answers
52
views
Is it safe to define static python object in C++ for Boost.Python?
I have a python script that calls some C++ code, and in the C++ part, I want to define some static python object, for example: static boost::python::list obj. However, according to pybind11 issue 1598 ...
0
votes
1
answer
196
views
Unable to install py3exiv2 in python on a MacBookPro
pip3 install py3exiv2 gives error:
In file included from src/exiv2wrapper.cpp:27:
src/exiv2wrapper.hpp:33:10: fatal error: 'exiv2/exiv2.hpp' file not found
33 | #include "exiv2/...
0
votes
0
answers
39
views
Segfault in Boost::python object converter after updating to boost 1_83_0
I have a python library written in c++ and specifically a function that retrieves a value from a redis server using boost async io:
python::object redis::connexion::py_mget(python::object keys) {
...
1
vote
1
answer
166
views
C++ Boost function too slow
I'm having trouble integrating the Boost library into my project. I'm developing a wrapper of boost library for python usage and i started from the "minkowski.cpp" example given by boost. ...
0
votes
2
answers
77
views
How to use boost::python raw_function without getting warning C4267?
I'm using boost 1.82, and if I use boost::python::raw_function, I get warning C4267 even if I explicitly use size_t.
#include <boost/python.hpp>
#include <iostream>
boost::python::object ...
0
votes
1
answer
1k
views
Pybind11/Nanobind: How to return class object and use methods from Python. How can I cast the C++ object to something whose methods I can use in Py
I'm not sure why I can't find any good discussion of this, I have been searching since yesterday.
How do you return a class object from C++ binding and use its methods in Python i.e.:
class A {
......
1
vote
1
answer
171
views
Boost Python: exposing std::list of enums
I have the following struct:
enum class Tag
{
QR,
April,
Chili
}
struct Options
{
std::list<Tag> tags;
}
that I want to expose in a Python package using boost python.
Here's my ...
0
votes
0
answers
75
views
Boost Python : exposing optional list of enums
I have the following structures:
enum class Tag
{
QR,
April,
Chili
}
enum class Constraint
{
Tag,
GPS,
User
}
struct Options
{
boost::optional<std::list<Tag>> ...
0
votes
1
answer
39
views
How to declare a C++ function that can take any python iterable?
We have functions like
void myf(const boost::python::list& l) {...}
is there a way to accept any python iterable, or less generically, any collection?
0
votes
1
answer
152
views
to_python_converter , is by value needed?
I have simplified my code to the following compilable code, with gcc13, boost 1.78 and python3.
#include <iostream>
#include <string>
#include <boost/python.hpp>
template <...
0
votes
1
answer
43
views
python::boost modules over aliases : RecursionError
So I am working with python boost. The goal for me is to be able to overload c++ functions from python modules. I have managed that, but I have observed a weird behavior when using aliases.
I have ...
0
votes
1
answer
46
views
How to make python3 import examine .so and ...-g.so as well?
We expose C++ code to python via boost.python. We produce release and debug builds.
release builds produce lib.so files
debug builds produce lib-g.so files.
Our python code then
import lib<mymodule&...
1
vote
1
answer
359
views
Boost/python.hpp is not correctly linked when using CMake and Conan
I am trying to use conan for the very first time to try to retrieve Boost.Python and start a project using it. I have having issues that once I open my visual studio solution I get a red underline ...
2
votes
1
answer
1k
views
How to build libboost-python.so in Boost 1.74
Boost build not generate libboost_python38.so.1.74.0 for python modules in my project.
I tried build boost libraries like this, but libboost_python38.so.1.74.0 not appears for me:
wget https://...
0
votes
1
answer
125
views
Linking error trying to make module with boost python
I'm trying to create example boost.python module, but i have only link errors
The boost was built with command
b2 --with-python address-model=64 toolset=msvc --build-dir=build link=shared install ...
0
votes
0
answers
143
views
Error When Importing Bond Python Library Written in Boost Python C++
I get this error:
undefined symbol: _ZN5boost6python15instance_holder8allocateEP7_objectmmm
which is basically undefined symbol: boost::python::instance_holder::allocate::object
How to solve that?
I ...
0
votes
1
answer
32
views
How to use a pre-defined input argument when exposing a class method with boost::python
I am trying to expose a C++ class to Python using Boost Python Library. I have a class with an array of 3 elements and I wish to be able to get the value of element by the names of "first", &...
0
votes
1
answer
100
views
Making a boost python array work with the for loop
I am trying to have an array using boost python
#include <boost/python.hpp>
#include <memory>
#include <vector>
class MyObject
{
public:
MyObject(int value)
: value_(...
0
votes
1
answer
467
views
Passing a function as function argument in Boost.Python
I have a C++ function ExecuteFunction that takes as input another function f.
I would like to expose ExecuteFunction in Python with Boost.Python, and call it from Python with either Python functions ...
2
votes
0
answers
361
views
Creating module with pybind11 and debugging it in Python at runtime crash
I'm re-posting my issue from https://github.com/pybind/pybind11/discussions/4477 to here as I'm not getting much luck there for now...
To summarize I have C++ application that has Python in it via ...
1
vote
0
answers
109
views
Exposing Python function with variadic arguments from c++
I would like to expose to python a function accepting required positional arguments,optional keyword arguments, variadic positional arguments, and variadic keyword arguments.
For example:
def f( a,b,c=...
0
votes
0
answers
83
views
Convert base class to derived class when returning object
I have classes and functions which I don't want to change, but I want to expose them to Python with some additional functionalities (Dunder Methods etc.). So what I have is derived class like follows:
...
0
votes
0
answers
157
views
Hold reference to Numpy array inside C++ object
I want to create C++ wrapper for Numpy array. For that purpose I need to hold reference to Numpy array (for returning it to Python later) and reference to raw data of that array.
For that I've wrote ...
2
votes
0
answers
81
views
Is there a way to get the type of something thrown?
I have a code calling some Python from C++ (with Boost.Python). I have an exception thrown when trying to get the error from Python. But my question is quite general :
If the execution throws ...
0
votes
0
answers
124
views
Error with valgrind on a code using boost::python
I try to track a memory leak in a code using boost::python.
I reduced my code to a simple main. This simple main run with valgrind without error/leak :
valgrind --leak-check=full --track-origins=yes /...
2
votes
1
answer
529
views
Including Boost Python libraries produces C2039 compiler error
I have built Boost_1.76 with the following configurations.
Compiler: MSVC 143
Build Tools: bootstrap.bat, b2 engine
Python Version: 3.7
b2 Command: b2 --build-dir=build/x64 address-model=64 threading=...
2
votes
1
answer
1k
views
Python cannot find Boost.Python module
I try to create a simple C++ module for python with Boost, but python gives me ModuleNotFoundError: No module named 'MyLib'.
The .py file is in the same location as MyLib.dll.
UPD: if i change dll to ...
-1
votes
1
answer
60
views
How can I create an instance of RuntimeError in boost python?
I have a requirement to create, but not throw, a python RuntimeError.
I'm using Boost python, the code so far:
static boost::python::object builtins = boost::python::import("builtins"); ...
0
votes
0
answers
63
views
BOOST::PYTHON Setting the namespace of a boost::python::object with cppyy
We are trying to set the namespace of a boost::python::object, with the following code
In PyROOTGlobals.h we declare:
#ifndef PyROOTGlobals_h
#define PyROOTGlobals_h
#include <boost/python.hpp>
...
0
votes
0
answers
447
views
Boost.Python - How do you raise a KeyError?
I have a Boost.Python function that I need to return a string or raise an exception if one does not exist. The code roughly looks like this (but isn't 100% exact)
#include <boost/python.hpp>
...
0
votes
0
answers
498
views
python cmake/boost can't find boost libraries
I try to compile the Frechet-CUDA package for python. I installed C++ via Visual Studio and installed dlib and cmake for python to compile the package. Furthermore added boost 3.18.
Still get the ...
0
votes
1
answer
205
views
Boost-Python: Expose a class to Python which is a subclass of a Python class (str)
I am trying to have a Boost Python function return a Python object which is a subclass of a Python builtin class (here str):
My first method involves creating the class in a Python module, mystr.py:
...
2
votes
0
answers
366
views
Pass C++ variable as reference to Python using Boost
I am trying to pass an argument by reference to a Python function from C++ using the Boost Python library (as well as the Boost Numpy extension). The object in question is an ndarray, and passing it ...
1
vote
1
answer
398
views
boost-python3 program crashes on exit
While porting program from boost-python2 to boost-python3, I came to situation, that boost program with embedded python3 crashes on exit, though same code built with python 2.7 works well. This case ...
0
votes
1
answer
277
views
libboost-python create module in C++-runtime and use it from pythin code, for python 3.x
I have a piece of software that embeds python using libboost-python. It creates a python module in C++ runtime, and then imports it from python code.
For python2.7 this works like this:
test_module.py
...
0
votes
1
answer
724
views
Using Boost Python 3.10 and C++ Classes
I'm really confused with initialzing C++ classes when usign boost::python. When compiling the follwing code with CMake I get no error, warning or something else at all:
#include <boost/python.hpp&...