python - 如何在 setup.py 中运行 Makefile?

标签 python distutils

我需要编译ICU使用它自己的构建机制。因此问题:

如何从 setup.py 运行 Makefile?显然,我只希望它在构建过程中运行,而不是在安装时运行。

最佳答案

我通常使用的方法是覆盖有问题的命令:

from distutils.command.install import install as DistutilsInstall

class MyInstall(DistutilsInstall):
    def run(self):
        do_pre_install_stuff()
        DistutilsInstall.run(self)
        do_post_install_stuff()

...

setup(..., cmdclass={'install': MyInstall}, ...)

我花了很长时间才从 distutils 文档和源代码中弄清楚,所以我希望它能帮您省去痛苦。

注意:您也可以使用此 cmdclass 参数来添加新命令。

关于python - 如何在 setup.py 中运行 Makefile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1754966/

相关文章:

python - linux tee 不能与 python 一起使用?

python - 如何正则表达式直到最后一次出现?

python - 如何在不使用子进程的情况下从 python 自动化脚本中运行 python 'sdist' 命令?

python - 如何安装 C++ 库的 python 绑定(bind)

python - 有没有一种方法可以比较两个 Excel 并执行诸如根据比较插入行之类的操作?

python - 如何替换循环数组中的子字符串[pandas]

python - 使用 google colab TPU 时出现 ValueError : slice index 0 of dimension 0 out of bounds.

Python distutils.扩展 : setting a concurrency level

python - Cython:使用distutils编译C++

python - 调用 `pip install` 时运行自定义任务