2017-02-26 46 views
1

我想在Python 3中使用开罗后端的Pango。我选择'cairocffi'是因为这里不相关的原因。我正在尝试运行the example in the documentation。它通过CFFI称呼Pango。示例的最开始部分包含'cairocffi'时'CompiledFFI'而不是'FFI'

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中看不到includecdef,set_source方法?主要问题是,我做错了什么?

回答

0

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

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

+0

这个混淆来自于'CompiledFFI'在文档中甚至没有提到。 – beroal

+0

对。 “FFI”和“CompiledFFI”这两种类型通常非常相似,但我在文档中写了一个注释(http://cffi.readthedocs.io/en/latest/ref.html#ffi-interface)。 –

+0

对不起,我在页面上找不到'CompiledFFI'。 – beroal

相关问题