2013-02-21 101 views
1

执行我喜欢让我的守护程序是自动启动后的setup.py安装是否有可能定义命令setup.py

壳,我可以通过归档此:

更新的rc.d kmsd默认21

在setup.py(disutil),该怎么做?

是否可以这样做,或者我只能让我的用户在安装后手动调用这个命令?

谢谢

回答

2

是的,这是可能的。我在我自己的代码中使用遗留构建系统预编译一些库。

像下面这样的东西应该可以工作,但我应该告诫它说我没有测试下面的代码。

from distutils.core import setup, Command 
import distutils.command.install as InstallCommand 
from subprocess import call 

class FinallyDoSomething(Command): 
    description = "Do my custom stuff" 
    user_options = [] 
    def initialize_options(self): 
     pass 

    def finalize_options(self): 
     pass 

    def run(self): 
     call(["update-rc.d", "kmsd", "defaults", "21"]) 

class NewInstall(InstallCommand): 
    sub_commands = InstallCommand.sub_commands + [ 
      ('custom_install', None),] 

setup(name='PackageName', 
     version='0.1', 
     #The rest of the setup config 
     cmdclass={ 
      'install': NewInstall, 
      'custom_install': FinallyDoSomething, 
      }, 
    ) 
+0

它的工作原理,谢谢 – Cody 2013-02-22 07:18:14

相关问题