开发者

Install libxml2 bindings for python3

The Problem

I’m trying to build libxml (libxml2-2.7.8) bindings for Python 3.2. 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!

Attempted Fixes

  1. Ported setup.py and generator.py (using 2to3, and some basic patches on generator.py)
  2. Patched libxml.c and types.c as follows:
    • replace PyInt* by PyLong*
    • replace PyString* by PyBytes*

Current Situation

Unfortunately, it still wasn’t enough. I ran python3.2 setup.py build and got the following error:

types.c:594:17: error: ‘PyInstanceObject’ undeclared (first use in this function)

I can’t find开发者_高级运维 the Python3 equivalent of PyInstanceObject!

Has anyone managed to compile libxml2 bindings for Python 3?

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. The trick here is to first update the bindings to use new-style classes, and then port to Python 3.

(Or use lxml, which wraps the libxml2 in a Pythonic XML classes).

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜