为什么我的 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])
So I have a C++ class that I made python wrappers for, and I made a setup.py file to compile it in order to use it in python. When I try to run python setup.py install I get the following error:
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
I don't think the problem is with the file being compiled, I think I must be setting up the setup.py wrong. Here is what my setup.py file looks like:
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])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题是源定义中的前导
'..'
。 Distutils 使用源文件的名称来生成临时文件和输出文件的名称,但不会对它们进行规范化。重新组织源代码树(或移动 setup.py 文件),这样您就不需要引用'../tools/...'
Your problem is the leading
'..'
in the source definitions. Distutils uses the names of the source files to generate names of temporary and output files, but doesn't normalize them. Reorganize your source tree (or move the setup.py file) so you don't need to reference'../tools/...'