CFFI 1.0 alpha0

51 views
Skip to first unread message

Armin Rigo

unread,
Apr 26, 2015, 11:15:04 AM4/26/15
to pytho...@googlegroups.com
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.

Alex Gaynor

unread,
Apr 26, 2015, 11:16:14 AM4/26/15
to pytho...@googlegroups.com
Hi Armin,

Does it support "modulename" being a dotted path?

Thanks,
Alex


--
-- python-cffi: To unsubscribe from this group, send email to python-cffi...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/python-cffi?hl=en
---
You received this message because you are subscribed to the Google Groups "python-cffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-cffi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
"I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084

Armin Rigo

unread,
Apr 26, 2015, 12:17:41 PM4/26/15
to pytho...@googlegroups.com
Hi Alex,

On 26 April 2015 at 17:16, Alex Gaynor <alex....@gmail.com> wrote:
> Does it support "modulename" being a dotted path?

Fixed!

It's not quite clear where recompile() will put the .so: apparently,
distutils will write it to "<tmpdir>/package/module.so", so that's
what you get. The "package" directory is created if it does not
exist, but no __init__.py is added. The tmpdir is by default "." for
now.


A bientôt,

Armin.
Reply all
Reply to author
Forward
0 new messages