1
I am trying to understand where and how are Python packages installed and stored on Linux and find the best location to store them. My repo is Debian Wheezy.
I would like to store all my custom Python modules in one folder.
I am confused, because
1. I can see certain packages (installed with apt-get), like pygame
in all the following places:
- /usr/share/pyshared/pygame
- /usr/lib/pyshared/python2.7/pygame
- /usr/lib/pyshared/python2.6/pygame
- /usr/lib/python2.7/dist-packages/pygame
- /usr/lib/python2.6/dist-packages/pygame
With some files being linked from pyshared -> to lib/python2.7/dist-packages
2. Some other packages are installed to /usr/share/pyshared
and then linked to /usr/lib/python2.6
and 2.7.
3. Finally, when I install something with easy_install it gets into /usr/local/lib/python2.7/dist-packages/
into something .egg.
In terms of all this chaos, what do you believe is the right way to keep custom modules and what is the best file format for them? Should single file modules should just be called something.py while multiple file modules should be in a folder with a __init__.py
in them? Is that right? Is there any reason to keep single-file modules in folders as well?
And most importantly where should I keep them? /usr/local/lib/python2.7/my-packages/
, or inside dist-packages?
I've often had this question or a variation of it. It seems important to me especially (thinking as a sysadmin) in terms of keeping one's systems predictable and understandable for others who may have to manage them as well. Essentially the question is "what is the accepted convention for locating custom packages?". Unfortunately I've yet to get a good answer, and experienced Python people seem to consider it a dumb question. But I think this is part of the cause of the 'chaos' you describe. The question is not 'what will work?' but 'what is least surprising?'. – robo – 2015-01-24T17:21:55.597