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

发布于 2024-09-10 16:52:44 字数 1087 浏览 5 评论 0原文

所以我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与他有关 2024-09-17 16:52:44

您的问题是源定义中的前导 '..' 。 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/...'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文