cppyy is a Python module for using C++ code inside python.
Questions tagged [cppyy]
59 questions
1
vote
1 answer
How to create a child class in python when using cppyy?
I use cppyy to allow python call C++ functions and classes. But I don't know how to create a child class of imported C++ function.
Here is my problem.
import cppyy
cppyy.include('/include/HSTradeApi.h') //include the CHSTradeSpi…

ERIC
- 460
- 6
- 16
1
vote
1 answer
how to load library in cppyy?
I am trying cppyy in python to import C++ files. I want to load HSMdApi.h and HSMdApi.lib. Here is the dir structure
Here is the code
import cppyy
cppyy.include('include/HSMdApi.h')
cppyy.load_library('win64/HSMdApi.lib')
I load the header file…

ERIC
- 460
- 6
- 16
1
vote
1 answer
Read char16_t* String with cppyy from c++
cppyy is the only Python package I've found for wrapping a C++ Lib using char16_t* strings under Linux. Given a function:
int ::func1(const char16_t* symbol, char16_t* data, const unsigned int length)
// [in] symbol, [out] data, [in] length
//…

araisch
- 1,727
- 4
- 15
1
vote
1 answer
How do I index array of classes from a pointer with cppyy
I have seen docs about array indexing for basic types in cppyy. I haven't figured out how to index an array of custom types.
take:
import cppyy
cppyy.cppdef("""
struct Foo
{
float var;
}
struct Bar
{
Foo* foo;
}
""")
If an array of…

Ken
- 693
- 1
- 7
- 15
1
vote
1 answer
Cppyy exclusion based on method arguments?
It is possible to exclude class methods in CPPYY based on their function arguments?
For example, suppose that a class has two constructors:
class A
{
A(int);
A(double);
};
Is it possible to select class A but exclude one of the two…

Bill Hart
- 359
- 2
- 15
1
vote
1 answer
cppyy - how to call a c++ function that accepts a set?
Suppose I have the following C++ function:
int summap(const map& m) {
...
}
I try to call it from Python using cppyy, by sending a dict:
import cppyy
cppyy.include("functions.hpp")
print(cppyy.gbl.summap({55:1,66:2,77:3}))
I get an…

Erel Segal-Halevi
- 33,955
- 36
- 114
- 183
0
votes
0 answers
converting cppyy returned objects to python objects
I have a cpp method that returns a tuple of two dimensional vectors of double values (std::tuplestd::vector, ...>. When calling the method through cppyy, I am getting a weird wrapper object representing the tuple and nested…

Carpet4
- 578
- 1
- 8
- 17
0
votes
0 answers
Trouble using cppyy to run c++ code that connects to a RabbitMQ instance with SSL connection
I am having trouble using cppyy to execute some c++ code which tries to connect to a RabbitMQ instance with SSL.
The code to start the SSL connection is very similar to the amqp_ssl_connect.c example here. Most notably where I am having issue is…

sohmahmood
- 11
- 3
0
votes
1 answer
Initializing std::map of pointers of objects in cppyy
I am trying to initialize a map from strings to unique pointers from cppyy. I am able to make a vector of pointers without issue, but I get some complaints from cppyy when I make a map. Here are my classes:
import cppyy
import cppyy.gbl as…

shouriha
- 79
- 6
0
votes
0 answers
Cppyy map of subclassed or templated objects
As a follow-up question to Using cppyy with rvalue pointers and maps (Apologies for not coming up with a simpler example)
I am attempted to initialize a NameToBasisModel(std::map>>&&…

shouriha
- 79
- 6
0
votes
1 answer
Cppyy pythonization with templates?
Is there a way to write pythonizations in cppyy that work for all templates?
I have a class in C++ that requires a template
template
Bound Bound::buildInclusiveBound(TValueType value) {
return…

shouriha
- 79
- 6
0
votes
1 answer
How do I call a function with an std::ostream& argument using cppyy?
I am using cppyy for a native c++ project. I have a function that takes in a std::ostream& object and I am not sure how to create something that calls it from python.
I have tried doing
import io
output =…

shouriha
- 79
- 6
0
votes
1 answer
Cppyy cmake build cannot find libclang
I am trying to build cppyy via cmake but I keep getting this error:
CPYY_MODULE_PATH: /usr/local/anaconda3/envs/bwcpp_env/lib/python3.10/site-packages/cppyy_backend/cmake
CMake Error at…

shouriha
- 79
- 6
0
votes
2 answers
Problem creating OpenMP enabled PCH programmatically with cppyy
I've been trying to generate a OpenMP enabled precompiled header (PCH) with cppyy
and have been failing so far. Instead of doing so manually each time as outlined in this answer, I'm looking for an automated solution.
So far, the broad method is to…

Thejasvi
- 200
- 1
- 11
0
votes
0 answers
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
namespace Kolophon{
class PyROOTGlobals {
…

Lukas Kretschmann
- 11
- 1