How can I run a Makefile in setup.py?

前端 未结 3 1099
借酒劲吻你
借酒劲吻你 2021-01-30 17:13

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

How can I run a Makefile from setup.py? Obviously, I only want it to run duri

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 17:57

    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}, ...)
    

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

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

提交回复
热议问题