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
0 answers

Variable not found in library when importing with CFFI

I am trying to load the following .h file: 3 typedef struct { 4 uint8_t clock_pin; 5 } pinout; 6 7 pinout foo = {.clock_pin = 5}; 8 pinout bar = {.clock_pin = 4}; Using the following python file: 1 from pathlib import Path 2 import cffi 3 4…
user2886057
  • 646
  • 1
  • 5
  • 15
0
votes
0 answers

cffi can't parse memcpy from string.h

I watched a very compelling lecture on unit testing C code with Python and I've been trying to write some test code using the strategy. When I attempted to run a very simple test, I receive the error: cffi.api.CDefError: cannot parse "extern void…
KG6ZVP
  • 3,610
  • 4
  • 26
  • 45
0
votes
1 answer

Typeerror when using CFFI to test C code using struct

I'm working on a cffi testing demo, and when I try to run the python tester file, it returns the following error: TypeError: initializer for ctype 'Car *' appears indeed to be 'Car *', but the types are different (check that you are not e.g. mixing…
0
votes
1 answer

Python CFFI doesn't copy typedef from cdef() into generated C file

I'm feeding a generated header file into ffi.cdef(), with a bunch of typedefs like this at the beginning: typedef enum { LE_GPIO_EDGE_NONE = 0, LE_GPIO_EDGE_RISING = 1, // ...etc... } le_gpio_Edge_t; Then I try to compile it: with…
Dmiters
  • 2,011
  • 3
  • 23
  • 31
0
votes
1 answer

Ctypes: DataTypes from C-definition

I have the address of a function and also its "c-like" representation (from llvmlite, but this is not that important). For a function, which adds up two double values and returns them the code would look like this: cfunc = CFUNCTYPE(c_double,…
hr0m
  • 2,643
  • 5
  • 28
  • 39
0
votes
1 answer

How to fix this stack overflow in this tkinter/exec()/cffi combination?

I have a Python-powered DSL which I execute through exec(). This DSL includes a native function calls through CFFI. I'm getting stack overflow (SO, you made it ungooglable!) crash when calling a native function which is just 2 C calls deep, with…
Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91
0
votes
1 answer

Using Python CFFI with .lib and bunch of .dll and .h files

I need to write Python2 wrapper for proprietary library, consists of few .h files (I made one big), bunch of .dll and one .lib file to link all this stuff. I think I need API level, because of all this `typedef' in .h files Script to create wrapper:…
alfnak
  • 1
  • 1
0
votes
1 answer

Installing Python cryptography package from source on Solaris 10

I am trying to install the Python cryptography package on a Solaris 10 system. I have built Python 2.7 and libffi from source in my home directory. I can build cffi by specifying the path to libffi: $ python setup.py build_ext --include-dirs…
0
votes
1 answer

Can CFFI use the same DLL with both Python 3.4 and 3.5?

This page documents the different versions of the Microsoft Visual C++ compiler needed for each Python version: https://wiki.python.org/moin/WindowsCompilers I would like to use MinGW instead of Microsoft to compile a C library for 64-bit Windows…
hiccup
  • 277
  • 2
  • 8
0
votes
1 answer

pip install -d not creating wheel for cffi

I'm trying to create "offline package" for python code. I'm running pip install -d -r requirements.txt The thing is that cffi==1.6.0 (inside requirements.txt) doesn't get built into a wheel. Is there a way I can make it? (I trying to…
Boaz
  • 4,864
  • 12
  • 50
  • 90
0
votes
1 answer

How to install Cffi python module on Windows 7 64-bit?

Is there a way to start working with cffi in the Windows 7 64-bit environment without using the MinGW ? What all packages need to be installed for the same?
user39602
  • 339
  • 2
  • 5
  • 13
0
votes
1 answer

Python CFFI - Unable to use formatted Python string as byte-array in function call

I'm learning various ways of how to include code written in C to Python because I have an API for a Microchip device which is pretty...tedious to work with and I would like to make my life easier in the future by adding a Python wrapper for it which…
rbaleksandar
  • 8,713
  • 7
  • 76
  • 161
0
votes
1 answer

Some confusion about gevent (cffi) setup

In Gevent 1.1, there are two backends, cython and cffi. What I confuse is _corecffi_build.py. In line 331, ffi.set_source('gevent._corecffi', _source, include_dirs=include_dirs) I do not know why ffi.set_source does not specify sources to include…
Jacky1205
  • 3,273
  • 3
  • 22
  • 44
0
votes
1 answer

Runtime error when trying to use pip

I have managed to royally screw myself over by doing something which seemed innocuous. i was getting the following error from my python script (brand['feed'] = the URL i'm making the request…
teebagz
  • 656
  • 1
  • 4
  • 26
0
votes
1 answer

Callback from "multiprocessing" with CFFI segfaults after ~100 iterations

A PyPy callback, that works perfectly (in an infinite loop) when implemented (straightforwardly) as method of a Python object, segfaults after approximately 100 iterations when I move the Python object into a separate multiprocessing process. In the…
stustd
  • 303
  • 1
  • 10