包括'cairocffi'

时间:2017-02-26 20:37:08

标签: python cairo python-cffi

我想在Python 3中使用Pango和Cairo后端。我选择'cairocffi'是出于与此无关的原因。我正在尝试运行the example in the documentation。它通过CFFI调用Pango。示例的开头

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

给出以下错误。

  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'

我一直在努力了解CFFI文档,但我完全迷失了。首先,CompiledFFI记录在哪里?其次,我为什么不在the FFI interface中看到includecdefset_source方法?主要问题是,我做错了什么?

1 个答案:

答案 0 :(得分:0)

看起来cairocffi被更新为使用更现代的方式使用cffi,但这使得这个例子过时了。你应该让cairocffi作者更新这个例子。

此处记录了

ffi.include()http://cffi.readthedocs.io/en/latest/cdef.html#ffi-ffibuilder-include-combining-multiple-cffi-interfaces。混淆来自这样一个事实:在现代等价物中,ffi对象将被称为ffibuilder,而不是在那个例子中(结构不同)。