如何使用默认 python 在 Mac OSX 上安装 PyCairo 1.10

发布于 2024-11-27 04:10:01 字数 65 浏览 0 评论 0原文

有人使用新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

妳是的陽光 2024-12-04 04:10:01

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

这就是它对我来说的工作原理。在 python waf configure 找不到 Python.h 后,我查看了 config.log 文件位于 build_directory 中,发现失败的真正原因是架构不兼容。waf 脚本尝试使用 i386 架构构建一个包含 CPython 调用的简单源文件,但失败了。因为我的Python是为 我想,你可以将 python 重建为通用二进制

文件,但是,可以使用 x86_64 架构来构建 pycairo


$ 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 架构构建的,在执行下面描述的步骤之前,请确保它也适合您。

brew 代表 homebrew 才能执行以下操作。步骤适合您。


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

  1. brew install cairo(版本1.10.2 截至今天)


  2. 获取 python 2.x 的 pycairo 源(如果你获取快照,它的名称为 py2cairo,而 pycairo 现在需要 python 3.x)。我使用了 ma​​ster 分支的源代码(提交 f3435910d8f5365b45ebd4216f4043383c9e3e19)

  3. 在您选择的编辑器中打开 wscript,找到行 env = ctx.env 在函数 configure 中并在其下方添加以下行

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

  4. 保存文件

  5. 在终端中运行这些命令:

    导出 CC=/usr/bin/gcc

    导出 PKG_CONFIG_PATH=/usr/local/Cellar/cairo/1.10.2/lib/pkgconfig/

    重要提示:只有当您通过自制程序安装 cairo 时,后一个路径才适用

  6. 然后运行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:

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

孤独陪着我 2024-12-04 04:10:01

对于任何回到这里的人,我能够根据 llimllib 的链接,使用稍微不同的方法在 OSX Lion 上安装 py2cairo。希望这有帮助:

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

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
肤浅与狂妄 2024-12-04 04:10:01

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文