Errors accessing Cairo from wx_cairocffi.py with OS X (10.11)

I have installed Cairo using MacPorts according to the guidelines in Phoenix:

$ port installed
The following ports are currently installed:

cairo @1.14.6_0+quartz (active)

It gets installed to /opt/local/lib/libcairo.dylib which isn’t on the search path in cairoccfi.dlopen() but adding

export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib

to the fwpy script that runs Python seems to do the trick.

However when I try to use Cairo, for example from demo/Cairo.py I get the error

File “/Volumes/IVY_E/GitHub/Phoenix/demo/Cairo.py”, line 34, in OnPaint
self.Render(dc)
File “/Volumes/IVY_E/GitHub/Phoenix/demo/Cairo.py”, line 48, in Render
ctx = wxcairo.ContextFromDC(dc)
File “/SoftDev/PyDevSrc7/DpMac_V710/env2.7/lib/python2.7/site-packages/wx/lib/wxcairo/init.py”, line 79, in ContextFromDC
return _ContextFromDC(dc)
File “/SoftDev/PyDevSrc7/DpMac_V710/env2.7/lib/python2.7/site-packages/wx/lib/wxcairo/wx_cairocffi.py”, line 56, in _ContextFromDC
surfaceptr = cairo_c.cairo_quartz_surface_create_for_cg_context(

AttributeError: cffi library ‘/opt/local/lib/libcairo.dylib’ has no function, constant or global variable named ‘cairo_quartz_surface_create_for_cg_context’

I’ve tried different variations within MacPorts - even tried using Brew - also Python 3.4 but all with the same effect.

Any suggestions please?

···


Regards
David Hughes
Forestfield Software

Just an update on my previous post. I haven’t really made any headway with this except to use
nm -gU libcairo.dylib
in Terminal to list all the entry points which confirms that all the cairo_quartz_ entries are there. But when I run the wxPython demo/cairo program in the Wing debugger it confirms that the imported cairo_c is <Lib object for ‘/opt/local/lib/libcairo.dylib’> and if I then enter
for item in dir(cairo_c):
print item

into the debug probe I get all the entry points listed except for the _cairo_quartz
__ entries, but what I do get is a whole set of cairo_win32*_ entry points. What!! ??

The above was done with the dev2352 Phoenix build. I have since updated to today’s dev2380 snapshot and it’s still the same.

Regards
David Hughes

Wing-Cairo-demo-01.tiff (975 KB)

David Hughes wrote:

Just an update on my previous post. I haven’t really made any headway with this except to use
nm -gU libcairo.dylib
in
Terminal to list all the entry points which confirms that all the cairo_quartz*_
entries are there. But when I run the wxPython demo/cairo program in the Wing debugger it confirms that the imported cairo_c is <Lib object for ‘/opt/local/lib/libcairo.dylib’> and if I then enter
for item in dir(cairo_c):
print item

into the
debug probe I get all the entry points listed except for the cairo_quartz*_
entries, but what I do get is a whole set of cairo_win32*_ entry
points. What!! ??

The above was done with the dev2352 Phoenix build. I have since updated to today’s dev2380 snapshot and it’s still the same.

I used the time machine again and submitted a PR to the cairocffi project to fix this. It looks like there has been a release since that was merged, so maybe you just need to update your cairocffi install?

···

https://github.com/SimonSapin/cairocffi/pull/86

Robin Dunn

Software Craftsman

http://wxPython.org

I downloaded the master zip file from the above and installed it on
OS X and initially it had no effect. Also pip reports no change in
version number (0.7.2)

However by running **pip uninstall cairocffi** before running **      python

setup.py install** the wxPython Cairo demo now seems to be
working. I am away until the end of the week so cannot check
everything yet, but it looks good. Thanks.

···

https://github.com/SimonSapin/cairocffi/pull/86

Robin Dunn


-- Regards
David Hughes
Forestfield Software