为什么我的setup.py脚本会出现此错误?

时间:2010-07-22 21:24:55

标签: c++ python wrapper setup.py

所以我有一个C ++类,我为它做了python包装,我创建了一个setup.py文件来编译它,以便在python中使用它。当我尝试运行python setup.py install时,我收到以下错误:

lipo: can't create output file: build/temp.macosx-10.5-fat3-2.7/../tools/transport-stream/TransportStreamPacket_py.o (No such file or directory)
error: command 'gcc-4.0' failed with exit status 1

我认为问题不在于正在编译的文件,我想我必须设置setup.py错误。这是我的setup.py文件的样子:

from distutils.core import setup, Extension

module1 = Extension('CL_TransportStreamPacket_py',
                sources = ['../tools/transport-stream/TransportStreamPacket_py.cpp'],

                include_dirs = ['.',
                    '../common',
                    '../tools/transport-stream'],

                library_dirs = ['common',
                    '../tools/transport-stream'],

                libraries = ['Common',
                    'TransportStream']

            )

setup (name = 'CL_TransportStreamPacket_py',
     version = '1.0',
     description = 'This is the transport stream packet parser',
     ext_modules = [module1])

1 个答案:

答案 0 :(得分:3)

您的问题是源定义中的前导'..'。 Distutils使用源文件的名称生成临时文件和输出文件的名称,但不对它们进行标准化。重新组织源树(或移动setup.py文件),这样您就不需要引用'../tools/...'