How to extend distutils with a simple post install script?

后端 未结 4 2557
我寻月下人不归
我寻月下人不归 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条回答
  •  误落风尘
    2020-12-01 03:13

    I dug through distutils source for a day to learn enough about it to make a bunch of custom commands. It's not pretty, but it does work.

    import distutils.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=dict(install=my_install), ...)
    

提交回复
热议问题