wiki:VirtualEnv

Version 4 (modified by Darren Weber, 16 years ago) ( diff )

--

Installing a Python Virtual Environment for Chimera

First, get the setuptools package installed. Note the following has some version specific details that need attention for any current installation. At the time of writing, this installation used a specific svn-build of Chimera (2010-08-05) and a specific version of setuptools for the version of python that was built for Chimera (python2.7). It also assumes that Chimera was installed with sudo privileges, but that is not necessary (this should work for a user installation too, without the sudo privileges).

$ sudo -i
# export CHIMERA=/opt/UCSF/Chimera64-2010-08-05
# export PATH=$PATH:$CHIMERA/bin/ 
# export LD_LIBRARY_PATH=$CHIMERA/lib
# wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
# sh setuptools-0.6c11-py2.7.egg --prefix=$CHIMERA

Now use these setuptools to install any python package into the Chimera specific python distribution. For example, install the virtualenv package, like so:

$ sudo -i
# export CHIMERA=/opt/UCSF/Chimera64-2010-08-05
# export PATH=$PATH:$CHIMERA/bin/ 
# export LD_LIBRARY_PATH=$CHIMERA/lib
# $CHIMERA/bin/easy_install-2.7 virtualenv
Searching for virtualenv
Reading http://pypi.python.org/simple/virtualenv/
Reading http://virtualenv.openplans.org
Best match: virtualenv 1.4.9
Downloading http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.4.9.tar.gz#md5=c49067cab242b5ff8c7b681a5a99533a
Processing virtualenv-1.4.9.tar.gz
Running virtualenv-1.4.9/setup.py -q bdist_egg --dist-dir /tmp/easy_install-eNIuwN/virtualenv-1.4.9/egg-dist-tmp-blYuR8
warning: no previously-included files matching '*.*' found under directory 'docs/_templates'
Adding virtualenv 1.4.9 to easy-install.pth file
Installing virtualenv script to /opt/UCSF/Chimera64-2010-08-05/bin

Installed /opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/virtualenv-1.4.9-py2.7.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

Now that virtualenv is installed in the Chimera python distribution, we can setup any additional custom virtual environments to add python packages into the development environment. As a regular user, the following will create a Chimera-specific development environment in ~/src/chimera-virtualenv:

$ export CHIMERA=/opt/UCSF/Chimera64-2010-08-05
$ export PATH=$PATH:$CHIMERA/bin/ 
$ export LD_LIBRARY_PATH=$CHIMERA/lib
$ mkdir -p ~/src
$ cd ~/src
$ $CHIMERA/bin/virtualenv chimera-virtualenv
New python executable in chimera-virtualenv/bin/python2.7
Also creating executable in chimera-virtualenv/bin/python
Installing setuptools.................done.
$ ll chimera-virtualenv/
total 20
drwxr-xr-x  5 dweber dweber 4096 2010-08-24 14:05 ./
drwxr-xr-x 45 dweber dweber 4096 2010-08-24 14:05 ../
drwxr-xr-x  2 dweber dweber 4096 2010-08-24 14:05 bin/
drwxr-xr-x  2 dweber dweber 4096 2010-08-24 14:05 include/
drwxr-xr-x  3 dweber dweber 4096 2010-08-24 14:05 lib/

Once this virtual environment is created, it can be activated and deactivated with the following commands (note how the system prompt changes to indicate that we have entered and left the virtual environment).

$ source ~/src/chimera-virtualenv/bin/activate
(chimera-virtualenv)$ deactivate
$ 

Now start the Chimera build of python and import the chimera module, like this:

$ source ~/src/chimera-virtualenv/bin/activate
(chimera-virtualenv)$ python
Python 2.7 (r27:82500, Aug  5 2010, 14:15:36) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/opt/UCSF/Chimera64-2010-08-05/share') 
>>> sys.path.append('/opt/UCSF/Chimera64-2010-08-05/lib')
>>> import chimera
>>> chimera.version.version
'alpha version 1.5 (build 31152) 2010-08-05 19:55:24 GMT'
Note: See TracWiki for help on using the wiki.