如何在软件包更新之间保留data_files? [英] How to keep data_files between package updates?

查看:138
本文介绍了如何在软件包更新之间保留data_files?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用setuptools.setup()data_files参数将配置文件安装到/etc和用户的主目录.但是,使用pip install <package-name>更新软件包会先卸载旧版本和所有配置文件,然后再安装新版本.

I'm using the data_files argument of setuptools.setup() to install config files to /etc and the users home directory. However updating the package with pip install <package-name> uninstalls the old version and all config files before it installs the new version.

如果更改了配置文件,如何在更新过程中保留它们?

How do I keep the config files during updates if they have been changed?

推荐答案

我非常怀疑鸡蛋或轮子的安装程序"能做到这一点.它们是相当原始的分发格式,适用于简单的事情(卸载以前的版本,安装新的覆盖文件),仅此而已.

I very much doubt that eggs or wheels "installers" can do that. They are rather primitive distribution formats suitable for simple things (uninstall the previous version, install the new one overriding files) but that's all.

要执行所需的操作,您可能需要一个真正的安装程序(rpm或deb)-它们可以保留更改的配置文件.但是它们很复杂,很难创建格式.

To do what you want you probably need a real installer (rpm or deb) — they can preserve changed config files. But they are complex, hard to create formats.

如果您坚持使用简单的滚轮,我建议您完全停止分发配置文件.而是分发配置文件的模板,并教用户从这些模板创建配置文件.然后,新版本将仅覆盖模板,而不会覆盖实际的配置文件.

If you insist on using simple wheels I can recommend stop distributing config files at all. Instead distribute config files' templates and teach users to create config files from these templates. Then new versions will only override templates but not real config files.

这篇关于如何在软件包更新之间保留data_files?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆