Hi all,
CFFI 1.0 has now reached "alpha 0" level. Sorry for the telegraphic
style of this mail: I'm writing it quickly in the hope that a few
other people would test it too.
First note that it has only been tested on CPython 2.7 on Linux for
now. Check it out from the usual repo:
hg clone
https://bitbucket.org/cffi/cffi
hg update -r cffi-1.0
Its main news is the following functions (details will still change soon):
_cffi1.make_c_source(ffi, "modulename", "...", "filename.c")
_cffi1.recompile(ffi, "modulename", "...")
which are similar to `ffi.verify("...")`, but not loading any
newly-compiled .so; instead they only creates a .c file --- a CPython
C extension module ---, and in the case of recompile(), it calls gcc
on it, via distutils.
This C extension module is meant to be created either manually or from
setup.py (details of that are yet to be sorted out). From the real
program/library, you then no longer import cffi at all. Instead, you
do "from modulename import ffi, lib". (This C extension module still
depends on the "_cffi_backend" extension module at runtime, but not on
any Python code.)
This basically works right now. Most tests pass, and largish examples
like curses work. See demo/_curses_build.py and demo/_curses.py for
how to organize the code. This is straight from PyPy's
"lib_pypy/_curses.py" file, split in two files: the ``ffi=FFI();
ffi.cdef("...");
ffi.verify("...")`` part has been moved to _curses_build.py, calling
``recompile()`` instead of ``verify()``. And in _curses.py the same part has
been replaced with just ``from _curses_cffi import ffi, lib``. No
other changes have been necessary; the result works on a curses-using
example. (Measuring the time to import "_curses", it is now
10x faster.)
The main missing feature is ffi.include(), but the rest is supposed to
work. Please try it out! :-)
A bientôt,
Armin.