[英]Install libxml2 bindings for python3
I'm trying to build libxml
( libxml2-2.7.8
) bindings for Python 3.2.我正在尝试为 Python 3.2 构建
libxml
( libxml2-2.7.8
) 绑定。 When I run the following:当我运行以下命令时:
./configure --with-python=/usr/bin/python3.2
The compilation of libxml2-2.7.8
works...but the Python bindings for libxml2-2.7.8
don't! libxml2-2.7.8
的编译工作......但libxml2-2.7.8
的 Python 绑定不起作用!
setup.py
and generator.py
(using 2to3
, and some basic patches on generator.py
)setup.py
和generator.py
(使用2to3
和generator.py
上的一些基本补丁)libxml.c
and types.c
as follows:libxml.c
和types.c
如下:
Unfortunately, it still wasn't enough.不幸的是,这仍然不够。 I ran
python3.2 setup.py build
and got the following error:我运行
python3.2 setup.py build
并得到以下错误:
types.c:594:17: error: ‘PyInstanceObject’ undeclared (first use in this function)
I can't find the Python3 equivalent of PyInstanceObject
!我找不到 PyInstanceObject 的
PyInstanceObject
等价物!
Has anyone managed to compile libxml2
bindings for Python 3?有没有人设法为 Python 3 编译
libxml2
绑定?
Did I miss something???我错过了什么??? Can anybody help?
有人可以帮忙吗? :(
:(
The PyInstanceObject is a part of the support for old style types, which is gone in Python 3 , and has been deprecated since Python 2.2. PyInstanceObject 是对旧样式类型的支持的一部分,它在 Python 3 中消失了,并且自 Python 2.2 起已被弃用。 The trick here is to first update the bindings to use new-style classes, and then port to Python 3.
这里的技巧是首先更新绑定以使用新样式的类,然后移植到 Python 3。
(Or use lxml, which wraps the libxml2 in a Pythonic XML classes). (或使用 lxml,它将 libxml2 包装在 Pythonic XML 类中)。
I'm not 100% sure what the replacement is, I've never done old-style classes in C, but I think it's simply a PyObject.我不是 100% 确定替换是什么,我从未在 C 中做过旧式类,但我认为它只是一个 PyObject。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.