Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
Questions tagged [python-extensions]
323 questions
1
vote
2 answers
Extending a virtual C++ class exposed via Boost.Python
I am trying to expose this C++ class using Boost.Python:
class VAlgorithm {
public:
VAlgorithm(const char *name);
virtual ~VAlgorithm();
virtual bool Initialize() = 0;
virtual bool Process() = 0;
virtual bool Finalize() = 0;
virtual…

Nicola Mori
- 777
- 1
- 5
- 19
1
vote
1 answer
Possible memory leaks
Could someone check if there is an memory leak? I am confused.
PyObject * somefunc(int function_id, int num_params, int * params){
PyObject * params_list=PyList_New(0);
for(int i=0; i < num_params; i++){
PyObject * val =…

user1618103
- 51
- 1
- 2
1
vote
1 answer
Crash calling C++ virtual member from Python extension
I'm trying to write a thin wrapper around some C++ classes to call them from Python. The specific problem is that if virtual is uncommented below then attempting to create a Foo() crashes the interpreter. I'm not interested in rewriting this code as…

Andrew
- 2,943
- 18
- 23
1
vote
1 answer
Integrating C and Python: ValueError: module functions cannot set METH_CLASS or METH_STATIC
I am making my first venture into integrating C and Python 2.7.3. For starters, I'm just trying to write a C module for Python that can do basic addition. (It is called npfind because once I figure this out, I want to write a find method for…

dpitch40
- 2,621
- 7
- 31
- 44
1
vote
1 answer
Can't load python extension module that exists
I'm trying to use thanos, which creates an extension module at runtime. Thanos is constantly failing as it cannot import that said extension it created at runtime.
I am baffled as to why this is the case.
At runtime (after compilation) the…

UsAaR33
- 3,536
- 2
- 34
- 55
1
vote
2 answers
Is it possible to include socketmodule.h in Python C extensions?
I'd like to invoke PySocketModule_ImportModuleAndAPI function defined in socketmodule.h in my Python C-extension.

Dmitry Trofimov
- 7,371
- 1
- 30
- 34
1
vote
1 answer
How to convert PyFrameObject to PyObject
Maybe I'm missing something, but here is a problem:
I'm tracing python code by C extensions and my trace function got PyFrameObject* frame. Now I want to process the frame by Python code(embedded or converted to C by Cython) but it deals with…

Dmitry Trofimov
- 7,371
- 1
- 30
- 34
0
votes
1 answer
Cython 1.1.2 and const correctness
I am experimenting with Cython to write a python extension for my C library. I have created a setup.py file - but when I try to build my pxd and pyx files, I get an error.
After some investigation, it appears that Cython cannot grok functions with…

Homunculus Reticulli
- 65,167
- 81
- 216
- 341
0
votes
1 answer
Build python wheel with precompiled shared library
When building a wheel of a Python extension module, how can I tell setup() to use an existing/precompiled shared library?
For awful horrible reasons, the SO/DLL has to be compiled by a build system that cannot be invoked by Python. (FWIW it's…

alexchandel
- 532
- 6
- 15
0
votes
1 answer
How to fix this issue "ERROR: Failed building wheel for insightface"
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for insightface
Failed to build insightface
ERROR: Could not build wheels for insightface, which is required to install…

kin
- 1
- 1
0
votes
1 answer
Undefined symbol at runtime. Import Python C++ extension
I have a python package (my_python_package), part of which is a C++ extension (my_ext) with a single function (my_ext_func). The extension depends on my C++ library (libmycpp) and my C++ library depends on libarrow. The problem is that I get an…

Jerome D Walker
- 15
- 4
0
votes
0 answers
How to type `PyObject* const*` in Cython
Let's take this as an example: reference
The definition of the type _PyCFunctionFastWithKeywords is:
PyObject *_PyCFunctionFastWithKeywords(PyObject *self,
PyObject *const *args,
…

Jim
- 450
- 2
- 10
0
votes
1 answer
Python Wheel that includes shared library is built as pure-Python platform independent none-any
I wish to use some C and CUDA code in my Python package (which I then call using ctypes). Because of the CUDA, it doesn't seem to be easy to use the traditional approach of a setuptools Extension, so I instead pre-compile the code to shared…

user3708067
- 543
- 5
- 12
0
votes
1 answer
Cython: Unable to cimport from `.pxd` file
I have a simple project directory and some simple files which failed to compile.
Directory structure:
cythonize: ROOT
|___ cythonize
|___ __init__.pxd
|___ __init__.py
|___ first.pxd
|___ first.pyx
|___ second.pxd
|___…

Jim
- 450
- 2
- 10
0
votes
1 answer
How to write a simple VTune wrapper script on Windows?
Question
How do I write a wrapper script for VTune for Windows?
The documentation provides a simple wrapper script example for bash:
#!/bin/bash
# Prefix script
echo "Target process PID: $VTUNE_TARGET_PID"
# Run VTune collector
"$@"
# Postfix…

Samufi
- 2,465
- 3
- 19
- 43