Questions tagged [python-extensions]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

323 questions
7
votes
2 answers

How to pass --debug to build_ext when invoking setup.py install?

When I execute a command python setup.py install or python setup.py develop it would execute build_ext command as one of the steps. How can I pass --debug option to it as if it was invoked as python setup.py build_ext --debug? UPDATE Here is a…
Gill Bates
  • 14,330
  • 23
  • 70
  • 138
7
votes
2 answers

Data corruption: Where's the bug‽

Last edit: I've figured out what the problem was (see my own answer below) but I cannot mark the question as answered, it would seem. If someone can answer the questions I have in my answer below, namely, is this a bug in Cython or is this Cython's…
Michael Trausch
  • 3,187
  • 1
  • 21
  • 29
7
votes
2 answers

Correct cyclic garbage collection in extension modules

Two sections of Python 2.7's documentation mentioned adding cyclic garbage collection (CGC) support for container objects defined in extension modules. The Python/C API Reference Manual gives two rules, i.e., The memory for the object must be…
liuyu
  • 1,279
  • 11
  • 25
6
votes
1 answer

Do function pointers remain valid across processes?

I have written an extension module that uses C++ function pointers to store sequences of function calls. I want to 'run' these call sequences in separate processes using python's multiprocessing module (there's no shared state, so no synchronization…
vsekhar
  • 5,090
  • 5
  • 22
  • 23
6
votes
0 answers

Python C Extension: Fatal Python error: PyThreadState_Get: no current thread

I am trying to build a C based Python extension that uses a ffmpeg libraries. Since there are a bunch of libraries I have to import. I used CMake. I followed the instructions from python doc The build with CMake goes fine without any issues. But…
Gatothgaj
  • 1,633
  • 2
  • 16
  • 27
6
votes
1 answer

creating numpy array in c extension segfaults

I'm just trying to start off by creating a numpy array before I even start to write my extension. Here is a super simple program: #include #include #include "Python.h" #include "numpy/npy_common.h" #include…
Alex Z
  • 1,449
  • 4
  • 20
  • 29
5
votes
2 answers

Import and use standard Python module from inside Python C extension

I have Python extension module written in C. I want to use in this C code one of the standard Python modules, for example os or shutil. How is best to do this?
zaharpopov
  • 16,882
  • 23
  • 75
  • 93
5
votes
5 answers

How to create python C++ extension with submodule that can be imported

I'm creating a C++ extension for python. It creates a module parent that contains a sub-module child. The child has one method hello(). It works fine if I call it as import parent parent.child.hello() > 'Hi, World!' If I try to import my function…
BlacKow
  • 281
  • 2
  • 12
5
votes
1 answer

Cmake on mac os x, link libraries with fullpath

I'm trying to build a python extension with cmake. This is the cmake list: cmake_minimum_required(VERSION 2.8) PROJECT(drtile) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) find_package(Vigra REQUIRED) find_package(Boost COMPONENTS python…
Luca Fiaschi
  • 3,145
  • 7
  • 31
  • 44
5
votes
1 answer

CMake pybind11 cannot create target because another target with the same name already exists, how to bypass?

I have code which successfully runs. Its CmakeLists.txt is: cmake_minimum_required(VERSION 3.15) project(rotapro3) set(CMAKE_CXX_STANDARD 14) add_executable(rotapro3 main.cpp): I want to use pybind for this project, and following the instructions, I…
user12948426
5
votes
1 answer

Cython C-level interface of package: *.pxd files are not found

In a nutshell I try to compile a cython extension called extension2 that cimports a file extension from a self-created package. When building extension2, I get the error that extension.pxd is not found though this file is exactly at the sepcified…
Samufi
  • 2,465
  • 3
  • 19
  • 43
5
votes
0 answers

Step from pdb in gdb when debugging c extension

I'm developing a C(++) extension for python. I have a library in C that I wrap using Swig. Unfortunately I have some error that I would like to debug that is within the C extension. My program makes heavy use of MsgBuffer class which I send over a…
hetepeperfan
  • 4,292
  • 1
  • 29
  • 47
5
votes
1 answer

Python C Extension Missing Function

While following a C extension for Python tutorial, my module seems to missing its contents. While building and importing the module have no problem, using the function in the module fails. I am using Python 3.7 on macOS. testmodule.c #define…
nedla2004
  • 1,115
  • 3
  • 14
  • 29
5
votes
1 answer

`PyTuple_Pack` segfault

I have a function foo in a Python Extension Module that should return a tuple of ints to Python. This can be easily done using Py_BuildValue: static PyObject* foo(PyObject* self, PyObject* args) { int a = 0; int b = 0; /* calculations…
MaxPowers
  • 5,235
  • 2
  • 44
  • 69
5
votes
1 answer

How to generate .pyi files for a compiled Python extension?

I build a compiled Python extension (.pyd file) with C++ and pybind11. I would like to generate a single Python interface .pyi file for my .pyd file. There are a few similar questions referring to the mypy stubgen module, however, this one produces…
Alex Tereshenkov
  • 3,340
  • 8
  • 36
  • 61
1 2
3
21 22