Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python - setup.py copy file to certain location

As part of the installation process I would like to copy a config file to user's home directory, i.e. ~/.foo.conf

What is the usual approach to do this with setup.py? Should I write code in setup.py to copy the file after the setup(), or is there some built-in mechanism in place for this kind of task?

Update

I ended up modifying the script to check if ~/.foo.conf exists on start up. If not, create a default conf. I also found this post which was useful.

like image 785
armandino Avatar asked Oct 09 '22 10:10

armandino


1 Answers

I think this might be a misuse of setuptools. If you want to stick to a setuptools install, you should probably look for a config file there, and advertise it loudly to your users, but if defaults are needed, they should be read from inside the package itself, using something like resource_stream so that you can be sure you will find it no matter wether setup was run from system installed easy_install, into a virtualenv, or by a packaging system like rpm.

in the latter case, actually placing such a config file would be impractical, since the system users don't exist at the time the rpm is built.

like image 70
SingleNegationElimination Avatar answered Oct 13 '22 10:10

SingleNegationElimination