从 Scons 控制 distutils

发布于 2024-08-23 09:38:57 字数 337 浏览 8 评论 0原文

我有一个使用 Scons 构建的 C++ 库,它最终链接到(除其他外)Python 扩展。

使用 scons 构建库后,我编写了一个标准 setup.py 脚本,我调用该脚本来构建和安装扩展。

我的主要问题是 setup.py 无法识别库何时被重建(仅当扩展的代码已更改时),因此每次重建库时,我都必须在再次构建之前“清理”扩展。另外,如果我更改目录结构,我宁愿只需要编辑 Scons 文件。最后,只需要调用 scons 而不是除了 setup.py 之外还必须调用 scons 稍微方便一些。

有谁知道如何将 distutils 集成到 Scons 中,以便它可以利用 Scons 关于哪些文件需要重建的知识?

I have a C++ library that I build using Scons which is eventually linked into (among other things) a Python extension.

Once I have built the library with scons, I have written a standard setup.py script which I call to build and install the extension.

My main problem is that setup.py does not recognize when the library has been rebuilt (only when the extension's code has been changed), so every time I rebuild the library, I have to "clean" the extension before building it again. Also, if I change the directory structure, I would prefer to only need to edit the Scons files. And finally, it's just slightly more convenient to need only call scons instead of having to call scons in addition to setup.py.

Does anyone know of a way to integrate distutils into Scons so that it can take advantage of the knowledge Scons has about which files need to be rebuilt?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

强者自强 2024-08-30 09:38:57

您可以从 SCons 执行任何命令行。请参阅编写您自己的构建器。然后,您可以通过 写入来检测给定文件格式的任何更改扫描仪

You can do any command line from SCons. See Writing Your Own Builders. Then, you can detect any changes for a given file format by writing a scanner.

§普罗旺斯的薰衣草 2024-08-30 09:38:57

我已经成功创建了 SConstruct 来编译用 Pyrex 编写的 Python 扩展。主要思想是从 distutils 获取适当的 C 编译器标志,然后设置您的环境。

在 scons wiki 上查看此页面:

I have successfully created SConstruct to compile extensions for Python written in Pyrex. The main idea is to get appropriate C-compiler flags from distutils and then setup your Environment.

Check this pages on scons wiki:

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