1

I want to use Pango with the Cairo backend in Python 3. I chose 'cairocffi' for reasons that are not relevant here. I am trying to run the example in the documentation. It calls Pango through CFFI. The very beginning of the example

import cairocffi
import cffi
ffi = cffi.FFI()
ffi.include(cairocffi.ffi)

gives the following error.

  File "/usr/lib/python3.6/site-packages/cffi/api.py", line 494, in include
    type(ffi_to_include).__name__,))
TypeError: ffi.include() expects an argument that is also of type cffi.FFI, not 'CompiledFFI'

I have been trying to understand the CFFI documentation, but I am completely lost. First, where is CompiledFFI documented? Second, why do not I see include, cdef, set_source methods in the FFI interface? And the main question is, what am I doing wrong?

4

1 回答 1

0

看起来 cairocffi 已更新为使用更现代的 cffi 使用方式,但这使示例过时了。您应该要求 cairocffi 作者更新示例。

ffi.include()记录在这里:http ://cffi.readthedocs.io/en/latest/cdef.html#ffi-ffibuilder-include-combining-multiple-cffi-interfaces 。混淆来自这样一个事实,即在现代等效项中,该ffi对象将ffibuilder在该示例中被调用(其结构不同)。

于 2017-02-26T21:31:26.863 回答