我找到了Question#1321270用于安装后。我目前的主要目标是 bdist_wininst,但我没有找到任何与卸载相关的内容...
澄清一下:
我想在安装后注册一个com服务器并在卸载前取消注册。
扩展答案:
然而,为了事情的完整性,ars 的答案似乎是正确的(我认为文档在这个主题上留下了一些改进的空间......):
我没有按照提及 Question#1321270 所建议的那样扩展了 distutils.command.install
,但编写了一个名为 scripts/install.py
的新 Python 脚本,并在 setup.py 中设置以下内容:
setup(
...
scripts=['scripts\install.py'],
options = {
...
"bdist_wininst" : {
"install_script" : "install.py",
...
},
}
)
安装时肯定会调用 install.py。看起来,尽管它(尽管文档所说)在卸载时没有被调用...
最佳答案
相同的安装后脚本将在卸载时使用不同的参数运行。请参阅docs欲了解更多信息:
This script will be run at installation time on the target system after all the files have been copied, with argv1 set to -install, and again at uninstallation time before the files are removed with argv1 set to -remove.
关于python - 如何使用简单的预卸载脚本扩展 distutils?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3383801/