如何使用默认 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为 waf 在 Mac OS X 上严重损坏:(
这就是它对我来说的工作原理。在
python waf configure
找不到 Python.h 后,我查看了 config.log 文件位于 build_directory 中,发现失败的真正原因是架构不兼容。waf 脚本尝试使用 i386 架构构建一个包含 CPython 调用的简单源文件,但失败了。因为我的Python是为 我想,你可以将 python 重建为通用二进制文件,但是,可以使用 x86_64 架构来构建 pycairo
:
重要 。 :我的 python 版本是为
x86_64
架构构建的,在执行下面描述的步骤之前,请确保它也适合您。brew 代表 homebrew 才能执行以下操作。步骤适合您。
现在,要安装 cairo 和 pycairo,我执行以下操作:
brew install cairo
(版本1.10.2 截至今天)获取 python 2.x 的 pycairo 源(如果你获取快照,它的名称为 py2cairo,而 pycairo 现在需要 python 3.x)。我使用了 master 分支的源代码(提交 f3435910d8f5365b45ebd4216f4043383c9e3e19)
在您选择的编辑器中打开
wscript
,找到行env = ctx.env
在函数configure
中并在其下方添加以下行env.append_unique('CFLAGS', ['-arch', 'x86_64'])
保存文件
在终端中运行这些命令:
导出 CC=/usr/bin/gcc
导出 PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.10.2/lib/pkgconfig/
重要提示:只有当您通过自制程序安装 cairo 时,后一个路径才适用
然后运行pycairo 的安装文件:
python waf 配置
python waf 构建
python waf 安装
这应该可以做到。如果它对您不起作用,我认为最好在 pycairo 邮件列表(如果有的话)上提出该主题。
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:
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:
brew install cairo
(version 1.10.2 as of today)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)
Open
wscript
in your editor of choice, locate the lineenv = ctx.env
in the functionconfigure
and add the following line below itenv.append_unique('CFLAGS', ['-arch', 'x86_64'])
Save the file
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
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).
对于任何回到这里的人,我能够根据 llimllib 的链接,使用稍微不同的方法在 OSX Lion 上安装 py2cairo。希望这有帮助:
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:
android的步骤几乎可以工作。
需要在第5步使用(来自llimllib):
export ARCHFLAGS='-arch x86_64'
,然后
python waf install
才能成功。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.