Where to put data

Martin P. Hellwig martin.hellwig at gmail.com
Wed Jan 25 21:16:34 EST 2012


On 25/01/2012 17:26, bvdp wrote:

<cut explanation of bikeshed argument, where do I put the darn things>

Well once you think about distributing, here is the guide line I use:

- If it is meant as a library that can be 'imported' in python:
 > site-packages is the place to be, some linux distros are rather 
creative with them so be careful.

- If it is a 'stand-alone' application that just happens to use the 
python interpreter as a dependency:
 > /usr/local/bin for the executable script and /usr/local/lib for the 
program module(s) itself, of course this is platform dependent, consult 
posix first and then distribution/os specific preferences.

- If the additional (binary) data is static in nature:
 > /usr/local/share is the right place (or whichever preference the 
distribution/os has)

- If the additional (binary) data is dynamic in nature (like databases) 
and the program is run as a daemon:
 > /usr/local/,  /var/ or /opt/

- If the additional (binary) data is dynamic and it is run per user:
 > $HOME/.[application name]/ (the famous dot files in your home folder).

All that is unix like of course, Windows tend to put it all in the 
application folder in the Program Files folder, and user specific data 
in the profiles Application Data.

Of course opinions vary so I can only say this is what I usually follow, 
with the wisdom bestowed upon me by unix admins that where much more 
experience then I ever will be and always had a fit when I didn't put it 
in the right directory.

YMMV
-- 
mph



More information about the Python-list mailing list