Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Has anyone installed pycairo 1.10 on the mac using the new waf build? Its failing on can't find python headers.

share|improve this question
add comment

3 Answers

up vote 13 down vote accepted

I think waf is seriously broken for Mac OS X :(

Here's how it worked for me. After python waf configure failed to find Python.h, I looked through the config.log file located in build_directory and found out that the true cause of failure was incompatible architecture. The waf script tries to build a simple source file with CPython calls in it using i386 architecture. It fails to do so, because my python is built for the x86_64 architecture.

I guess, you could rebuild python as a universal binary, I haven't tried that. It is possible, however, to build pycairo using the x86_64 architecture. Here's how.


My setup:

$ python --version
Python 2.7.2

$ type python
python is /usr/local/bin/python

$ file /usr/local/bin/python
/usr/local/bin/python: Mach-O 64-bit executable x86_64

$ brew --version
0.8

Importrant: my python version is built for the x86_64 architecture. Make sure it is also the case for you before performing the steps described below.

brew stands for homebrew. You must use it instead of fink or MacPorts in order for the following steps to work for you.


Now, to install cairo and pycairo I do the following:

  1. brew install cairo (version 1.10.2 as of today)
  2. Get pycairo source for python 2.x (if you get a snapshot, it is named py2cairo, whereas pycairo now requires python 3.x). I used the source from master branch (commit f3435910d8f5365b45ebd4216f4043383c9e3e19)
  3. Open wscript in your editor of choice, locate the line env = ctx.env in the function configure and add the following line below it

    env.append_unique('CFLAGS', ['-arch', 'x86_64'])

  4. Save the file

  5. Run these commands in your terminal:

    export CC=/usr/bin/gcc

    export PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.10.2/lib/pkgconfig/

    Important: the latter path will only work for you if you installed cairo via homebrew

  6. Then run the waf commands described in the pycairo's INSTALL file:

    python waf configure

    python waf build

    python waf install

This should do it. If it doesn't work for you, I think it's better to raise the topic on the pycairo mailing list (if it has one).

share|improve this answer
add comment

For anyone coming back to this, I was able to get py2cairo installed on OSX Lion with a slightly different approach, based on llimllib's link. Hope this helps:

python waf clean
export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.7/
export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/2.7/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/2.7/lib:$LD_LIBRARY_PATH
export LINKFLAGS='-search_dylibs_first  -L /Library/Frameworks/Python.framework/Versions/2.7/lib/'
export ARCHFLAGS='-arch x86_64'
export CC=/usr/bin/gcc-4.2
export PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.10.2/lib/pkgconfig/

python waf configure --prefix=$PYTHONPATH
python waf build
python waf install
share|improve this answer
add comment

android's step almost works. one needs to use (from llimllib):

export ARCHFLAGS='-arch x86_64

in step 5, and then python waf install can succeed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.4.23.1561\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nos"], "copyright__copyright__copyright": ["\n\npython waf configure --prefix=$PYTHONPATH\npython waf build\npython waf install\nshare|improve this answer\nadd comment\n\nandroid's step almost works. one needs to use (from llimllib):\n\nexport ARCHFLAGS='-arch x86_64\n\nin step 5, and then python waf install can succeed.\n\nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}