Monday, January 17, 2011

Creating a "Virtual" Python

Creating a "Virtual" Python
http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python
If you are on a Linux, BSD, Cygwin, or other similar Unix-like operating system, but don't have root access, you can create your own "virtual" Python installation, which uses its own library directories and some symlinks to the site-wide Python.

In the simplest case, your virtual Python installation will live under the ~/lib/python2.x, ~/include/python2.x, and ~/bin directories. Just download virtual-python.py and run it using the site-wide Python. If you want to customize the location, you can use the --prefix option to specify an installation base directory in place of ~. (Use --help to get the complete list of options.)

When you're done, you'll have a ~/bin/python executable that's linked to the local Python installation and inherits all its current libraries, but which allows you to add as many new libraries as you want. Simply use this new Python in place of your system-defined one, and you can modify it as you like without breaking anything that relies on the system Python. You'll also still need to follow the standard installation instructions to install setuptools and EasyInstall, using your new ~/bin/python executable in place of the system Python.

Note that if you were previously setting a PYTHONPATH and/or had other special configuration options in your ~/.pydistutils.cfg, you may need to remove these settings before running virtual-python.py. This is because your new Python executable will not need any custom configuration for the distutils or EasyInstall; everything will go to the correct ~/lib and ~/bin directories automatically.

You should, however, also make sure that the bin subdirectory of your installation prefix (e.g. ~/bin) is on your PATH, because that is where EasyInstall and the distutils will install new Python scripts.


http://pypi.python.org/packages/2.5/S/Sphinx/Sphinx-1.0.6-py2.5.egg#md5=72f4365e790eda127234257646232451

========================
-bash-3.2$ module load python
-bash-3.2$ python virtual-python.py
Creating /home/ba01/u117/wdi/lib/python2.5
Creating /home/ba01/u117/wdi/lib/python2.5/site-packages
Creating /home/ba01/u117/wdi/include/python2.5
Creating /home/ba01/u117/wdi/bin

Copying /apps/coates/Python-2.5.2/bin/python to /home/ba01/u117/wdi/bin
You're now ready to download ez_setup.py, and run

/home/ba01/u117/wdi/bin/python ez_setup.py
-bash-3.2$ which python
/apps/coates/Python-2.5.2/bin/python

-bash-3.2$ which python
/apps/coates/Python-2.5.2/bin/python


-bash-3.2$ /home/ba01/u117/wdi/bin/python ez_setup.py
Processing setuptools-0.6c11-py2.5.egg
Copying setuptools-0.6c11-py2.5.egg to /autohome/u117/wdi/lib/python2.5/site-packages
Removing setuptools 0.6c9 from easy-install.pth file
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /home/ba01/u117/wdi/bin
Installing easy_install-2.5 script to /home/ba01/u117/wdi/bin

Installed /autohome/u117/wdi/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

===
notes: a better one which is an extention of virtual-python is "virtualenv.py"
http://pypi.python.org/pypi/virtualenv#downloads

No comments:

Post a Comment