I use "setuptools" for packaging Python projects and can't get one thing. I wrote small utility for personal use and it has a configuration file I want to place under ~/.config/workon/config.json, so I do it like this: https://github.com/ReturnedVoid/workon/blob/master/setup.py#L15. And then install my utility like this: https://github.com/ReturnedVoid/workon/blob/master/Makefile#L20.
It works BUT there are some problems:
- Sometimes (I don't know why) when I install a new version of the utility, the configuration file is overwritten
- "pip" knows nothing about the configuration file and does not remove it when I remove the package
- If I try to install it with
python3 -m pip install .command, the configuration file is installed relative to the "site-packages" (not what I want)
I also tried to override "setuptools" install command to copy the configuration file but it solves only the (1) problem described above.
So the question is: is there a way to simply copy my configuration file to ~/.config/... so it would be removed by pip uninstall?
Perhaps there is some better way to work with user configuration?
Update: I see these options for my case:
- Describe the configuration format and its expected location in the documentation. So let a user create a config file if he needs it
- Build some distribution package that is capable of doing this. For example Debian package...
- Generate config file on the initial utility run
But none of them are pleasant :) Would be much convenient for me to clone the project, run make install, fill the config file once and forget about it.