【发布时间】:2013-03-31 04:40:28
【问题描述】:
我直接使用 Cython 文档中的基本“hello world”演示。除非我尝试在同一个 setup.py 文件中导入 py2app,否则它工作正常:
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"])]
)
只要我为我的 Cython 模块预先生成 .c 文件,Py2app 本身就可以正常工作。但如果我没有,那么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 py2app,build_ext 可以正常工作并且我在编译中得到了缺少的中间步骤:
...
gcc-4.2 not found, using clang instead
cythoning helloworld/helloworld.pyx to helloworld/helloworld.c
building 'helloworld' extension
...
那么,py2app 破坏 Cython 的原因是什么?我能做些什么呢?显然,我只想为我的项目创建一个 setup.py。
我有从 PyPI 安装的 Cython 0.18 和 py2app 0.7.2。我将 Mac OS X 10.8 与 python.org Python 2.7.3 一起使用,而不是 Apple 的构建。
【问题讨论】:
-
当您将“import py2app”替换为“import setuptools”时会发生什么? Py2app 本身不会修补 distutils,但会使用 setuptools。
-
另外:这可能与分发问题跟踪器中的this issue 有关。
-
万岁,这就是问题所在。
import setuptools也破坏了 Cython。安装distribute(0.6.36) 而不是setuptools(0.6.c11) 修复了它。请提交作为答案,我会接受...