[cairo] Cannot import PyCairo in Python 3.0 (ImportError: dlopen / "Expected in: flat namespace")
Gerdus van Zyl
gerdusvanzyl at gmail.com
Mon Jan 5 07:49:48 PST 2009
Pycairo is actually a c-extension that wraps the cairo API with
objects for surface, context, etc. It's _cairo.so/_cairo.dll the
__init__.py is just a convenience for the python import system. The
python C API has changed so changes are needed (string to unicode and
int/longs merged). I am sure it will happen sometime :-)
In my own cairo using python library (uxpython.com) I'm sticking to
2.5/2.6 for quite a while at least till cairo/pango/pywin32 is ported.
On Mon, Jan 5, 2009 at 3:44 PM, Philipp Schumann <phil at roxority.com> wrote:
> Hi, thanks for getting back!
> Sounds reasonable, except all "Pycairo" is *actually* "doing" is importing a
> dynamic library (.so) written in and compiled from C. I can't imagine the
> semantics of that having changed to drastically in 3.0, so I was wondering
> whether anyone here has some experience with 3.0 as well and could give me a
> hint. Maybe I'll ask in some 3.0 mailing lists or forums, too.
> As you said, "it's a fairly straightforward binding". So I can't comprehend
> how this C library possibly *could* (technically) be "recompiled against"
> py3k. "Pycairo" itself is "just" the __init__ one-liner, no? 2to3 changed
> that for me so I don't think that's the problem.
>> At the very least you will need to compile pycairo/cairo yourself and
>> pycairo against py3k. It's a fairly straightforward binding so errors
>> should be fixable. That being said it won't be trivial. Any reason why
>> you are moving to Python 3.0 so fast? Since it's a breaking release
>> expect a few years before everything ported.
> Yeah, basically my code base is still in its early stages but will be
> project of a few years to come. I've only got 1 or 2 months worth of code at
> that point, I'm far from release to production but I know I will eventually
> have to upgrade to py3k, so I'd rather have it there *now*, even if rough
> around the edges. Most of the other libs I use were either already "ported"
> or I could do it myself painlessly with 2to3, no headaches or
> troubleshooting involved, thankfully. That includes mako, Werkzeug, couchdb,
> simplejson, httplib2. So for me the upgrade isn't that "breaking". Except
> for Cairo, but heck, at the end of the day it's "just" C bindings, so I'm
> thinking it should be possible to somehow "rebind" that, no?
> Any of the Cairo core hackers fancy giving it a spin? Maybe it's an easy
> hack, otherwise don't bother and I'll revert to 2.6 for now... Shamefully,
> I've never done any C or else I'd already be getting my teeth into that at
> that point now.
More information about the cairo