python - 如何使用简单的预卸载脚本扩展 distutils?

标签 python setuptools distutils

我找到了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/

相关文章:

python - Attrs 参数在 URLColumn 中不起作用(Django-tables2)

python - python中opencv阈值的最小blob大小

python - 无法构建轮子 - 错误 : invalid command 'bdist_wheel'

python - 如何在 setup.py 中执行(安全的)bash shell 命令?

python - setup.py:先运行 build_ext

python - Numpy 中 zeros 函数的性能

python - PyMySQL:查询大量行失败

python - 为什么 pip 安装我的包的旧版本?

python - 如何使用 SVN 和 distutils 为 Python 包分配版本号?

Python 安装程序,将一个模块安装为另一个模块的子模块?