简体   繁体   中英

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, ie ~/.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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM