cffi is a Foreign Function Interface for Python which enables C code to be called easily from Python code.

(Note that calling Fortran from Python is also very straightforward by using Fortran 2003 C bindings.)

User instructions

An old version of cffi is installed on all machines. Newer versions are available via the modules system. To add it to your environment run:

$ module load cffi/1.10.0

Documentation and examples can be found at

The cffi module also includes pycparser, a python module for parsing C code (which is unlikely to be of direct use).



Admin notes

cffi is already installed as other packages we need depend upon it, as is its dependency pycparser. After installing libffi-dev from the Debian repository, the latest version can easily be installed for both python2 and python3 using:

... code-block bash:

PYTHONUSERBASE=/common/debian/9.1/PythonPackages/python/2.7/cffi/cffi-1.10.0 pip install --upgrade cffi
PYTHONUSERBASE=/common/debian/9.1/PythonPackages/python/3.5/cffi/cffi-1.10.0 pip3 install --upgrade cffi