【问题标题】:py2app import breaks cythonpy2app 导入会破坏 cython
【发布时间】: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 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。

我有从 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) 修复了它。请提交作为答案,我会接受...

标签: python cython py2app


【解决方案1】:

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

解决方案是安装更新版本的 setuptools 或分发。

【讨论】:

  • 为了完整起见,我确实在 PyPI 上提供了最新版本的 setuptools。当然,Distribute 是 setuptools 的直接替代品,包括 Cython 修复程序。
猜你喜欢
  • 2017-02-04
  • 2018-10-20
  • 1970-01-01
  • 2019-12-07
  • 1970-01-01
  • 1970-01-01
  • 2012-11-04
  • 1970-01-01
  • 2016-08-14
相关资源
最近更新 更多