0

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:

  1. Sometimes (I don't know why) when I install a new version of the utility, the configuration file is overwritten
  2. "pip" knows nothing about the configuration file and does not remove it when I remove the package
  3. 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:

  1. Describe the configuration format and its expected location in the documentation. So let a user create a config file if he needs it
  2. Build some distribution package that is capable of doing this. For example Debian package...
  3. 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.

garrywreck
  • 53
  • 5
  • Similar questions have been asked and answered already. Some I could find are [this one](https://stackoverflow.com/a/59354676), and [this one](https://stackoverflow.com/a/64459990). – sinoroc Jun 24 '21 at 20:18

0 Answers0