Questions tagged [python-cffi]

Foreign Function Interface for Python calling C code. The aim of this project is to provide a convenient and reliable way of calling C code from Python.

Foreign Function Interface for Python calling C code. The aim of this project is to provide a convenient and reliable way of calling C code from Python.

More Details

216 questions
0
votes
1 answer

Why can't the embeddable Python distribution locate native modules?

I'm trying to build a standalone distribution of WeasyPrint for Windows. I downloaded and unpacked the embeddable Python 3.8 ZIP file to a directory called dist. Then, in MSYS2, I used a full Python 3.8 interpreter with Pip to install WeasyPrint…
David Brown
  • 35,411
  • 11
  • 83
  • 132
0
votes
1 answer

calling a fortran dll from python using cffi with multidimensional arrays

I use a dll that contains differential equation solvers among other useful mathematical tools. Unfortunately, this dll is written in Fortran. My program is written in python 3.7 and I use spyder as an IDE. I successfully called easy functions from…
ThlHckmnn
  • 5
  • 4
0
votes
0 answers

How to emit a PyQt-signal out of a cffi-callback

I am a bit stuck right now. This is more of a "how to approach this problem the right way" kind of question since I dont even know what exactly to type into google. I got a scientific camera from thorlabs which only provides a C DLL as API. I wrote…
0
votes
1 answer

What does "MemoryError: Stack overflow" mean while releasing memory using CFFI?

This question follows this one. I use CFFI to create a DLL and I call it from a C++ application. I was questioning myself to find how to release memory allocated by the DLL and I follow the idea mention by @metal in its answer. Here is now my Python…
Pierre
  • 1,942
  • 3
  • 23
  • 43
0
votes
1 answer

Why my app crashes when I free a char* allocated by a DLL generated with CFFI?

I'm using CFFI to generate a DLL: import cffi ffibuilder = cffi.FFI() ffibuilder.embedding_api(''' char* get_string(); ''') ffibuilder.set_source('my_plugin', '') ffibuilder.embedding_init_code(''' from my_plugin import ffi, lib …
Pierre
  • 1,942
  • 3
  • 23
  • 43
0
votes
2 answers

TypeError: initializer for ctype 'unsigned int *' must be a cdata pointer, not bytes

I try to convert PIL image to leptonica PIX. Here is my code python 3.6: import os, cffi from PIL import Image # initialize leptonica ffi = cffi.FFI() ffi.cdef(""" typedef int l_int32; typedef unsigned int l_uint32; struct …
ZdPo Ster
  • 300
  • 5
  • 12
0
votes
2 answers

Python CFFI enum from string name

I have an enum defined in Python cffi. How do I instantiate it by name? The docs say how to get the string name from enum, but not how to create it. ffibuilder = FFI() ffibuilder.cdef('typedef enum { dense, sparse } dimension_mode;') dim =…
drhagen
  • 8,331
  • 8
  • 53
  • 82
0
votes
0 answers

getting error installing python package brypt and cffi on raspbian stretch

I am trying to install brypt that has dependency on cffi, but this is landing into the error shown below: $ pip install bcrypt Collecting bcrypt Using cached…
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
0
votes
1 answer

cffi.error.FFIError: multiple declarations of function

I am using CFFI to automatically wrap a DLL using the API - out of line approach. This is actually done via Continuous Integration and has worked well so far. To make this possible, the DLL header file is preprocessed in Visual Studio and the…
Gregory Kuhn
  • 1,627
  • 2
  • 22
  • 34
0
votes
1 answer

can't install cffi with python3

I install from source code cffi with command "sudo python3 setup.py install" and get this error running install running bdist_egg running egg_info writing cffi.egg-info/PKG-INFO writing dependency_links to cffi.egg-info/dependency_links.txt writing…
zngDuong
  • 113
  • 1
  • 1
  • 5
0
votes
0 answers

How to get the pointer in a C function with unknown length using CFFI?

The title of this question may be a little confusing. I want to call a C function in python with cffi. It's a compression function. Part of the function looks like this: int compression_float_3d(float* array, int nx, int ny, int nz) { ... void*…
0
votes
0 answers

raise AttributeError(name) AttributeError: LCC_GetChannelHandle

I am very new in python cffi. I have to access my temprature module by using its Index or with its channel name. I am trying with both as you can see in my QmixTC class. I am getting attribute error. In other class, there is no errors. Can someone…
Ravi Mevada
  • 63
  • 3
  • 13
0
votes
1 answer

cffi error when compiling faster rcnn pytorch

I'm trying to compile faster_rcnn_pytorch using the instructions given here: https://github.com/longcw/faster_rcnn_pytorch I get this error: (p27) [$USER@compute-1-5 faster_rcnn]$ ./make.sh Traceback (most recent call last): File "setup.py", line…
snazziii
  • 471
  • 2
  • 10
  • 23
0
votes
2 answers

PYPY, CFFI import error cffi library '_heap_i' has no function, constant, or global variable named 'initQueue'

So I am trying to use cffi to access a c library quickly in pypy. I am using my macpro with command line tools 9.1 specifically I am comparing a pure python priority queue, with heapq, with a cffi, and ctypes for a project. I have got code from…
channon
  • 362
  • 3
  • 16
0
votes
1 answer

Why does bitbake recipe for python-cffi fail on do_fetch

Not sure is this is the right place to ask this: I've been struggling with trying to create a recipe to compile python-cffi for the dora branch of bitbake and have had no luck yet. There seems to be several recipes out there but non work for me.…
P Moran
  • 1,624
  • 3
  • 18
  • 32