How to extend distutils with a simple post install script?

后端 未结 4 2559
我寻月下人不归
我寻月下人不归 2020-12-01 03:09

I need to run a simple script after the modules and programs have been installed. I\'m having a little trouble finding straight-forward documentation on how to do this. It l

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 03:15

    I couldn't make Joe Wreschnigs answer work and tweaked his answer analogous to the extending distutils documentation. I came up with this code which works fine on my machine.

    from distutils import core
    from distutils.command.install import install
    ...
    class my_install(install):
        def run(self):
            install.run(self)
            # Custom stuff here
            # distutils.command.install actually has some nice helper methods
            # and interfaces. I strongly suggest reading the docstrings.
    ...
    distutils.core.setup(..., cmdclass={'install': my_install})
    

    Note: I didn't edit the answer of Joe since I am uncertain why his answer wasn't working on my machine.

提交回复
热议问题