2013-03-31 37 views
0

我使用基本的“hello world”演示直接从Cython文档中取出。py2app import breaks cython

import py2app 
from distutils.core import setup 
from distutils.extension import Extension 
from Cython.Distutils import build_ext 

setup(
    cmdclass = {'build_ext': build_ext}, 
    ext_modules = [Extension("helloworld", ["helloworld.pyx"])] 
) 

Py2app本身工作正常,只要我预先生成的.c文件我用Cython模块:除非我尝试导入py2app在同一个setup.py文件,它工作正常。但是,如果我没有,那么build_ext失败:

running build_ext 
gcc-4.2 not found, using clang instead 
building 'helloworld' extension 
clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c helloworld.c -o build/temp.macosx-10.6-intel-2.7/helloworld.o 
clang: error: no such file or directory: 'helloworld.c' 
clang: error: no input files 
error: command 'clang' failed with exit status 1 

如果我在setup.py注释掉import py2appbuild_ext工作正常,我得到我的编译缺少中间步骤:

... 
gcc-4.2 not found, using clang instead 
cythoning helloworld/helloworld.pyx to helloworld/helloworld.c 
building 'helloworld' extension 
... 

那么py2app是什么打破了Cython?我能做些什么呢?显然,我想为我的项目准备一个setup.py。

我有Cython 0.18和py2app 0.7.2,从PyPI安装。我正在使用Mac OS X 10.8和python.org Python 2.7.3,而不是Apple的版本。

+0

当你用“import setuptools”替换“import py2app”时会发生什么? Py2app本身并不修补distutils,但确实使用setuptools。 –

+0

另外:这可能与分发问题跟踪器中的[此问题](https://bitbucket.org/tarek/distribute/issue/195)有关。 –

+0

Hooray,就是这个问题。 '进口setuptools'也打破了Cython。安装'distribute'(0.6.36)而不是'setuptools'(0.6.c11)修复它。请提交作为答案,我会接受... – jab

回答

1

构建失败,因为py2app使用setuptools,并且旧版本的setuptools(和distribute)与Cython不兼容。

解决方法是安装更新版本的setuptools或发布。

+0

为了完整起见,我确实在PyPI上提供了setuptools的最新版本。当然,分发是setuptools的直接替代品,并且包含Cython修补程序。 – jab