As outlined in the documentation I've added the data_files
variable to setup.py
to install a config file when the package is installed:
setup(...,
data_files=[('/greg/home/package', ['config']),]
)
How to install the config file if one does not exist, but not:
install --upgrade
?For example, when I try to uninstall the package, the config file is included in the list of files to be deleted.
$ pip uninstall package
Uninstalling package-0.1.0:
...
/home/greg/package/config
Proceed (y/n)?
How to only install config file if one does not exist and use the user's version otherwise?
Generally, most packages handle config files like this by only providing an example config, and requiring the user to change the filename or move it to a different location so that it won't get overwritten or deleted.
Another thing that some packages will do is provide a command line script to help generate the config (e.g. Sphinx, Django) in a user specified location, instead of packaging a config with the project.