CFFI 1.8.2 released

46 views
Skip to first unread message

Armin Rigo

unread,
Sep 6, 2016, 5:21:05 AM9/6/16
to pytho...@googlegroups.com
Hi all,

CFFI 1.8.2 has been released. (Versions 1.8 and 1.8.1 are only inside
PyPy 5.4.0 and 5.4.1, which have been released recently.)

Two main changes:

* On CPython 3.x, the C extension modules generated by cffi (not cffi
itself!) are now using CPython's official "limited C API". This means
that the same compiled .so/.dll should work without recompilation on
any version >= 3.2. The name produced by distutils is still
version-specific. To get the version-independent name, you can rename
it manually to ``NAME.abi3.so``, or use the very recent setuptools 26.

* ffi.from_buffer() can now be used on byte strings, getting the
``char *`` address of the C string directly. This was not allowed
because PyPy couldn't support it---we can make the string non-movable,
but the blocker was that the strings in PyPy are not zero-terminated!
So from PyPy 5.4 all strings are allocated with space for one extra
character---an extremely minor overhead---and we write a zero at the
end when ffi.from_buffer() is called. Similarly, when we call
``lib.func("abc")``, PyPy would always make a copy of the string
because the original wasn't zero-terminated; now neither PyPy nor
CPython need to duplicate the string.


A bientôt,

Armin.

Alex Gaynor

unread,
Sep 6, 2016, 7:12:01 AM9/6/16
to pytho...@googlegroups.com
Wheels are uploaded.

Alex


--
-- python-cffi: To unsubscribe from this group, send email to python-cffi+unsubscribe@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+unsubscribe@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: D1B3 ADC0 E023 8CA6

Daniel Holth

unread,
Sep 14, 2016, 9:25:16 PM9/14/16
to python-cffi, ar...@tunes.org
On Tuesday, September 6, 2016 at 5:21:05 AM UTC-4, Armin Rigo wrote:
Hi all,

CFFI 1.8.2 has been released.  (Versions 1.8 and 1.8.1 are only inside
PyPy 5.4.0 and 5.4.1, which have been released recently.)

Two main changes:

* On CPython 3.x, the C extension modules generated by cffi (not cffi
itself!) are now using CPython's official "limited C API".  This means
that the same compiled .so/.dll should work without recompilation on
any version >= 3.2.  The name produced by distutils is still
version-specific.  To get the version-independent name, you can rename
it manually to ``NAME.abi3.so``, or use the very recent setuptools 26.

Fantastic.

Wheel >= 0.30 or the wheel pre-release 'pip install --pre --upgrade wheel' will tag wheels to go with this feature. Put a section in setup.cfg, and you should be able to generate a wheel tagged to work on all CPython greater than that version.

[bdist_wheel] 
py_limited_api=cp32

As a reminder, this only affects Python 3; the flag is ignored on Python 2. Before you publish you should double-check that any shared objects inside the archive indeed have the .abi3.so filename, or just .dll on Win32, and you should test the actual binaries on the target versions of CPython.

pip >= 8.2 is expected to support these wheels. At the time of writing, you still have to install pip from git to install the wheel, unless you point pip directly at the wheel file:

pip install git+https://github.com/pypa/pip#egg=pip --upgrade

Hopefully this entire stack will save people a lot of time distributing binaries for multiple CPython 3.x releases.

Armin Rigo

unread,
Sep 15, 2016, 4:58:57 AM9/15/16
to pytho...@googlegroups.com
Hi Daniel,

Thanks for this extra information!

On 15 September 2016 at 03:25, Daniel Holth <dho...@gmail.com> wrote:
> Wheel >= 0.30 or the wheel pre-release 'pip install --pre --upgrade wheel'
> will tag wheels to go with this feature. Put a section in setup.cfg, and you
> should be able to generate a wheel tagged to work on all CPython greater
> than that version.
>
> [bdist_wheel]
> py_limited_api=cp32

For reference, the modules produced by cffi should always work on
CPython >= 3.2; there is no need to require a more recent version in
this case.

This feature hasn't been extensively tested, so if someone has got
positive or negative feedback, please write it to this list :-)


A bientôt,

Armin.

Daniel Holth

unread,
Sep 15, 2016, 8:40:38 AM9/15/16
to python-cffi, ar...@tunes.org
Also, according to PEP 384, Windows users should link to python3.dll. None of this is automatic. Try it out and let us know!
Reply all
Reply to author
Forward
0 new messages