There’s a great feature in Python versions 2.6 and up that I hardly see being used; it’s the ability to install modules and packages in a per-user local directory. I like this feature since it doesn’t have any super-user power requirements and lets me install packages, modules and even scripts in my own Home directory and use it just as normally as the other global files.
To do so, one must first create the local site-packages directory, and then place the required package or module file or folder under it. The following commands are all for UNIX. ~/ expands to the user’s $HOME automatically.
# To create the required directory
mkdir -p ~/.local/lib/python2.6/site-packages
Now place the module or package folder under this directory, or link to it for achieving the same installation effect as you would with a global site-packages directory. For example, for my django copy from svn I’d do:
ln -s ~/.django-svn/django-trunk/django ~/.local/lib/python2.6/site-packages/django
Running the Python interpreter (in the same user account) will show this working:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>
So there you have it, when you want a package just for your user account while developing just put it under the local site-packages directory. Python automatically adds this to its path (PYTHONPATH).
References: PEP 370 (Has notes for OS X and Windows users)