如何使用默认python在Mac OSX上安装PyCairo 1.10 [英] How to install PyCairo 1.10 on Mac OSX with default python

查看:89
本文介绍了如何使用默认python在Mac OSX上安装PyCairo 1.10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人使用新的waf版本在Mac上安装了pycairo 1.10吗?其失败无法找到python标头.

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

推荐答案

我认为waf在Mac OS X中严重损坏了:(

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

这就是它为我工作的方式.在python waf configure无法找到Python.h之后,我浏览了位于 build_directory 中的 config.log 文件,发现失败的真正原因是架构不兼容. waf脚本尝试使用i386体系结构在其中包含CPython调用的情况下构建简单的源文件.这样做失败了,因为我的python是为x86_64体系结构构建的.

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.

我想,您可以将python重建为通用二进制文件,但我还没有尝试过.但是,可以使用x86_64体系结构构建pycairo.就是这样.

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.

我的设置:

$ 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

重要提示:我的python版本是为x86_64体系结构构建的.在执行下面描述的步骤之前,请确保您也遇到这种情况.

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表示 homebrew .您必须使用它而不是fink或MacPorts才能使以下步骤为您工作.

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

现在,要安装cairo和pycairo,请执行以下操作:

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

  1. brew install cairo(截止到今天的版本 1.10.2 )
  2. 获取python 2.x的pycairo源(如果获取快照,其名称为 py2cairo ,而 pycairo 现在需要python 3.x).我使用了来自 master 分支的源代码(提交f3435910d8f5365b45ebd4216f4043383c9e3e19)
  3. 在选择的编辑器中打开wscript,在函数configure中找到行env = ctx.env,并在其下方添加以下行

  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'])

保存文件

在终端中运行以下命令:

Run these commands in your terminal:

export CC=/usr/bin/gcc

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

重要提示:仅当您通过自制软件安装cairo时,后一条路径才对您有用

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

然后运行pycairo的INSTALL文件中所述的waf命令:

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

python waf configure

python waf build

python waf install

这应该做到.如果对您不起作用,我认为最好在pycairo邮件列表中提出该主题(如果有的话).

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).

这篇关于如何使用默认python在Mac OSX上安装PyCairo 1.10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆