scu*_*bbo 8 python pip setuptools setup.py
我想在运行时运行一些自定义代码pip uninstall
,清理在安装时创建的文件.我该怎么办呢?
我在setup.py中使用以下命令运行自定义安装代码:
from setuptools import setup
from setuptools.command.install import install
class CustomInstallCommand(install):
def run(self):
#Custom code here
install.run(self)
...
setup(
...
cmdclass = {
'install':CustomInstallCommand
}
)
Run Code Online (Sandbox Code Playgroud)
但尝试类似的setuptools.command.uninstall
或from setuptools.command.install import uninstall
失败的东西,因为那些模块/名称不存在.
正如其他人所说:强烈建议不要这样做 for security reasons and even if you find a way to do it now, is likely to break in the near feature.
这同样适用于安装命令,而不仅仅是卸载命令。所以,请不要走这条路。
Python 打包(包括 pip)将走向完全声明式,无需运行托管包中的任何代码。
归档时间: |
|
查看次数: |
523 次 |
最近记录: |