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
67
votes
19 answers

No module named _cffi_backend

I have Python 2.6 in my Linux rhel-5. I have installed pip and required CFFI packages. When I try to run a sample CFFI program: ffi = FFI() it says: File "/usr/lib/python2.6/site-packages/cffi/api.py", line 56, in __init__ import _cffi_backend…
Ash
  • 809
  • 1
  • 8
  • 14
32
votes
2 answers

How to include external library with python wheel package

I want to create package for python that embeds and uses an external library (.so) on Linux using the cffi module. Is there standard way to include .so file into python package? The package will be used only internally and won't be published to…
vvladymyrov
  • 5,715
  • 2
  • 32
  • 50
31
votes
5 answers

How to pass a Numpy array into a cffi function and how to get one back out?

I am developing an audio algorithm using Python and Numpy. Now I want to speed up that algorithm by implementing a part of it in C. In the past, I have done this using cython. Now I want to do the same thing using the new cffi. For testing purposes,…
bastibe
  • 16,551
  • 28
  • 95
  • 126
27
votes
3 answers

pip cffi package installation failed on osx

I am installing cffi package for cryptography and Jasmin installation. I did some research before posting question, so I found following option but which is seems not working: System Mac OSx 10.9.5 python2.7 Error c/_cffi_backend.c:13:10: fatal…
bhushya
  • 1,317
  • 1
  • 19
  • 33
16
votes
3 answers

How to pip install cairocffi?

How do I install cairocffi through pip? cairocffi is a CFFI-based drop-in replacement for Pycairo https://github.com/SimonSapin/cairocffi. I'm trying to install it on Ubuntu 14.04: alvas@ubi:~$ cat…
alvas
  • 115,346
  • 109
  • 446
  • 738
15
votes
1 answer

Why is cffi so much quicker than numpy?

I have been playing around with writing cffi modules in python, and their speed is making me wonder if I'm using standard python correctly. It's making me want to switch to C completely! Truthfully there are some great python libraries I could never…
Tim
  • 2,134
  • 3
  • 26
  • 40
13
votes
1 answer

Python-C integration: Ctypes, CFFI or create a Binary Module

Basically I want to make a Python program call functions written in C. So (as far as I know) my options are: CTypes/CFFI Create a DLL/SO/DyLib containing the C functions and access them using CTypes or CFFI. Apparently CFFI is way faster with the…
romulof
  • 357
  • 2
  • 12
12
votes
5 answers

Pip error installing cryptography on Big Sur

Using pip version 20.2.4, Python 3.8.2 and Big Sur 11.0.1. When I run pip install cryptography, I get this error: Building wheels for collected packages: cffi Building wheel for cffi (setup.py): started Building wheel for cffi (setup.py):…
MDalt
  • 1,681
  • 2
  • 24
  • 46
12
votes
1 answer

How can use CFFI to call an existing C function given the source code?

I have a C source/header file that are part of a bigger project. I would like to test this as a unit, independent of the real project. While it would be possible to do this in C by creating a new project with a different main(), I would like to see…
detly
  • 29,332
  • 18
  • 93
  • 152
11
votes
1 answer

How to install cffi package on AWS Beanstalk

This question looks the same as this post, but since there was no answer, I am re-asking here. I have a Django project to be deployed on AWS Beanstalk, which is using a package cffi. When I run eb deploy, the error logs looks like: ...... …
lpounng
  • 570
  • 6
  • 27
10
votes
3 answers

Failed to install "Cairocffi"

I'm working with python3, and i'm trying to install " cairocffi" on Ubuntu. To do this, i've successfully installed: python-dev libffi-dev cffi But when i've trying to install "cairocffi" with pip install cairocffi,I got: File…
Sam
  • 523
  • 2
  • 5
  • 14
8
votes
3 answers

Docker fails to install cffi with python:3.9-alpine in Dockerfile

Im trying to run the below Dockerfile using docker-compose. I searched around but I couldnt find a solution on how to install cffi with python:3.9-alpine. I also read this post which states that pip 21.2.4 or greater can be a possible solution but…
panos
  • 328
  • 1
  • 4
  • 16
8
votes
2 answers

Native bridge between Python and Dalvik or AAF

Is there any project that bridges Python and Dalvik in same address space? That is an object created in one language can be registered as a listener in the other and vice versa? -- Python could be CPython or PyPy; Dalvik could be full Android…
Dima Tisnek
  • 11,241
  • 4
  • 68
  • 120
7
votes
0 answers

TypeError: from_buffer() cannot return the address of a unicode object

While updating a tool to python3, I have been facing this issue on MacOS. print(args.secret) h = hmac.HMAC(args.secret.decode("hex"),hashes.SHA512(),backend=default_backend()) Output 39830c786a16 h = hmac.HMAC(hex(int(args.secret, 16)),…
Sprite
  • 350
  • 1
  • 5
  • 17
7
votes
0 answers

What's the way to install Microsoft Visual C++ 14.0 for CFFI that takes the least harddrive space?

I want to write Python software that uses CFFI. CFFI itself throws the error: distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":…
Christian
  • 25,249
  • 40
  • 134
  • 225
1
2 3
14 15