1

I have spent the last several nights trying to install py2cairo on Mac OSX Lion using gcc-4.2 and Python2.6, attempting a number of the approaches mentioned in these links (among many others; as a new user, I can post only two links):

http://www.niconomicon.net/blog/2011/10/09/2120.wrestling.python.snow.leopard

How to install PyCairo 1.10 on Mac OSX with default python

Unfortunately, I'm still running into a problem with the wrong header files being found. See below for my environment settings and the error output from waf build. I'd greatly appreciate any pointers. Thanks!

Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ env
MANPATH=/sw/share/man:/usr/share/man:/usr/local/share/man:/usr/X11/man:/usr/local/mysql/man:/sw/lib/perl5/5.12.3/man:/usr/X11R6/man
TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/8r/2kt_yqyx2dg2g83m0dyhcy740000gn/T/
LIBRARY_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/lib
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
Apple_PubSub_Socket_Render=/tmp/launch-bnnjZo/Render
TERM_PROGRAM_VERSION=303
OLDPWD=/private/tmp
TERM_SESSION_ID=3A9C4E28-D669-4134-A333-A13920514ED7
USER=dr_steve_kramer
LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/6.3/lib:/Library/Frameworks/Python.framework/Versions/6.3:
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-c3CJUO/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
Apple_Ubiquity_Message=/tmp/launch-pYg8fw/Apple_Ubiquity_Message
PATH=/Library/Frameworks/Python.framework/Versions/6.3/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/bin/f2j-0.7/bin:/usr/local/jaxws-ri:/usr/X11R6/bin
MKL_NUM_THREADS=1
C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/include
PWD=/private/tmp/py2cairo-1.10.0
LANG=en_US.UTF-8
JAXWS_HOME=/usr/local/jaxws-ri
CXX=g++-4.2
SHLVL=1
HOME=/Users/dr_steve_kramer
CFLAGS=-I/usr/include/gcc/darwin/4.2/
LINKFLAGS=-search_dylibs_first  -L /Library/Frameworks/Python.framework/Versions/6.3/lib/
PYTHONPATH=/Library/Frameworks/Python.framework/Versions/6.3/bin
LOGNAME=dr_steve_kramer
ACLOCAL_FLAGS=-I/usr/local/Cellar/pkg-config/0.25/share/aclocal
PKG_CONFIG_PATH=/sw/bin/pkg-config
ARCHFLAGS=-arch x86_64
INFOPATH=/sw/share/info:/sw/info:/usr/share/info
CC=/usr/bin/gcc-4.2
DISPLAY=/tmp/launch-CzK5Wg/org.x:0
_=/usr/bin/env
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ python2.6 waf configure
  ./options()
Setting top to                           : /private/tmp/py2cairo-1.10.0 
Setting out to                           : /private/tmp/py2cairo-1.10.0/build_directory 
  ./configure()
Checking for 'gcc' (c compiler)          : ok 
Checking for program python              : /Library/Frameworks/Python.framework/Versions/6.3/bin/python 
python executable '/Library/Frameworks/Python.framework/Versions/6.3/bin/python' different from sys.executable '/Library/Frameworks/Python.framework/Versions/6.3/Resources/Python.app/Contents/MacOS/Python'
Checking for python version              : (2, 6, 6, 'final', 0) 
Checking for library python2.6           : yes 
Checking for program python2.6-config    : /Library/Frameworks/Python.framework/Versions/6.3/bin/python2.6-config 
Checking for header Python.h             : yes 
Checking for program pkg-config          : /sw/bin/pkg-config 
Checking for 'cairo' >= 1.10.0           : yes 
Configuration:
PREFIX                                   : /usr/local
LIBDIR                                   : /usr/local/lib
'configure' finished successfully (1.577s)
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ python2.6 waf build
  ./options()
Waf: Entering directory `/private/tmp/py2cairo-1.10.0/build_directory'
  ./build()
  src/build()
[1/9] c: src/cairomodule.c -> build_directory/src/cairomodule.c.1.o
[2/9] c: src/context.c -> build_directory/src/context.c.1.o
[3/9] c: src/font.c -> build_directory/src/font.c.1.o
[4/9] c: src/path.c -> build_directory/src/path.c.1.o
[5/9] c: src/pattern.c -> build_directory/src/pattern.c.1.o
[6/9] c: src/matrix.c -> build_directory/src/matrix.c.1.o
[7/9] c: src/surface.c -> build_directory/src/surface.c.1.o
[8/9] subst: pycairo.pc.in -> pycairo.pc
In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
                 from ../src/pattern.c:32,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
                 from ../src/surface.c:32,
                 from ../src/matrix.c:32In file included from /Library/Frameworks/Pyth:
:
/usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85on.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85/usr/include/gcc/darwin/4.2/stdarg.h:5:2: ,
                 from ../src/cairomodule.c:32:
error: :
,
                 from ../src/path.c:32 /usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85#error ,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85"This header only supports __MWERKS__." :
,
                 from ../src/context.c:32error: /usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
                 from ../src/font.c:32error: 
#error /usr/include/gcc/darwin/4.2/stdarg.h:5:2::
:
"This header only supports __MWERKS__." #error /usr/include/gcc/darwin/4.2/stdarg.h:5:2:/usr/include/gcc/darwin/4.2/stdarg.h:5:2:
"This header only supports __MWERKS__."error:    #error 
error: "This header only supports __MWERKS__."#error error: error: 
"This header only supports __MWERKS__."#error #error 
"This header only supports __MWERKS__.""This header only supports __MWERKS__."

In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/wchar.h:111,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:120,
                 from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85,
                 from ../src/matrix.c:32:
/usr/include/gcc/darwin/4.2/stdarg.h:5:2: error: #error "This header only supports __MWERKS__."
Community
  • 1
  • 1

2 Answers2

0

If you haven’t solved this yet, try cairocffi: http://packages.python.org/cairocffi/

Simon Sapin
  • 9,790
  • 3
  • 35
  • 44
0

In case anyone is still have issues with py2cairo on OSX. I was able to get running by using install_name_tool. The config/build process was working and finding the correct version of python. However the compiled binary was linked against the incorrect version of python. This appears to be a bug in waf build system.

To fix the problem...

$ cd /usr/local/lib/python2.7/site-packages/cairo
$ otool -L _cairo.so 
_cairo.so:
    /Users/charlie/Downloads/py2cairo/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.2.0)
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
$ sudo install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Library/Frameworks/Python.framework/Versions/2.7/Python _cairo.so 
$ otool -L _cairo.so 
_cairo.so:
    /Users/charlie/Downloads/py2cairo/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.2.0)
    /Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

You can then import and use cairo in the version of python that you ran the waf script with.

Charles
  • 1,820
  • 13
  • 16