问题
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?
回答1:
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.
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.
来源:https://stackoverflow.com/questions/47241274/how-to-keep-data-files-between-package-updates