如何在setup.py中运行Makefile? [英] How can I run a Makefile in setup.py?

查看:83
本文介绍了如何在setup.py中运行Makefile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to compile ICU using it's own build mechanism. Therefore the question:

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

How can I run a Makefile from setup.py? Obviously, I only want it to run during the build process, not while installing.

推荐答案

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

The method I normally use is to override the command in question:

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 文档和源代码,所以我希望它可以减轻您的痛苦。

This took me quite a while to figure out from the distutils documentation and source, so I hope it saves you the pain.

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

Note: you can also use this cmdclass parameter to add new commands.

这篇关于如何在setup.py中运行Makefile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆