[chimera-dev] adding python packages to chimera environment

Darren Weber dweber at cgl.ucsf.edu
Fri Aug 20 13:25:02 PDT 2010


This an example of getting some packages installed into the Chimera 
python environment.  In my case, I was interested in using the spyder 
IDE within the Chimera python installation.

http://packages.python.org/spyder/

First, get the setuptools (easy_install) package:

$ sudo -i
# export PATH=$PATH:/opt/UCSF/Chimera64-2010-08-05/bin/
# export LD_LIBRARY_PATH=/opt/UCSF/Chimera64-2010-08-05/lib
# sh /home/dweber/Downloads/setuptools-0.6c11-py2.7.egg 
--prefix=/opt/UCSF/Chimera64-2010-08-05/

That gets 'easy_install' working with the Chimera python installation.

Now for the spyder IDE.  It requires PyQt4, so it's not trivial, but the 
following seems to build and install OK (against an Ubuntu package 
install for Qt4, not a custom build of Qt4 in foreign; the wget commands 
fetch linux-specific downloads):

$ sudo -i
# wget 
http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.5.tar.gz
# tar zxvf sip-4.10.5.tar.gz
# cd sip-4.10.5
# /opt/UCSF/Chimera64-2010-08-05/bin/python2.7 configure.py
# make
# make install
# cd ..
# wget 
http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-x11-gpl-4.7.4.tar.gz
# tar zxvf PyQt-x11-gpl-4.7.4.tar.gz
# cd PyQt-x11-gpl-4.7.4
# update-alternatives --config qmake  #select qmake-qt4 option
# /opt/UCSF/Chimera64-2010-08-05/bin/python2.7 configure.py 
--no-designer-plugin --qmake=/usr/bin/qmake-qt4
...<snip>...
The PyQt Python package will be installed in
/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages.
PyQt is being built with generated docstrings.
PyQt is being built with 'protected' redefined as 'public'.
The PyQt .sip files will be installed in
/opt/UCSF/Chimera64-2010-08-05/share/sip/PyQt4.
pyuic4, pyrcc4 and pylupdate4 will be installed in
/opt/UCSF/Chimera64-2010-08-05/bin.
...<snip>...
#make
#make install

That should satisfy the deps for spyder.  Then use easy_install to get 
spyder installed, like so:

# /opt/UCSF/Chimera64-2010-08-05/bin/easy_install spyder

Then to run spyder with a chimera-like env, the following seems to work:

# export CHIMERA=/opt/UCSF/Chimera64-2010-08-05
# export LD_LIBRARY_PATH="$CHIMERA/lib/"
# export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
# export TCLLIBPATH="{$CHIMERA/lib}"
# unset TK_LIBRARY
# unset TIX_LIBRARY
# export LD_PRELOAD=libotf.so
# export PATH=$PATH:$CHIMERA/bin
# unset PYTHONHOME
# unset PYTHONPATH
# $CHIMERA/bin/spyder

Within the spyder interactive console, it reports running python 2.7 and 
I see:

 >>> import sys
 >>> sys.path
['', '/opt/UCSF/Chimera64-2010-08-05/bin', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/spyder-1.1.4-py2.7.egg', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/pyflakes-0.4.0-py2.7.egg', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/rope-0.9.3-py2.7.egg', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python27.zip', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/plat-linux2', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/lib-tk', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/lib-old', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/lib-dynload', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages', 
'/opt/UCSF/Chimera64-2010-08-05/lib/python2.7/site-packages/PIL']
 >>>

This is not quite the right path (and maybe LD_LIBRARY_PATH etc.), but a 
few tweaks get it working, i.e.:

 >>> 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'

This may not be a complete config/setup, but it's close.  The spyder 
interface provides autocompletion, auto help-inspection, debug 
facilities, workspace, etc.

If anyone finds a better way to do this, please let me know.  There may 
be better ways to do this with virtualenv, see
http://clemesha.org/blog/2009/jul/05/modern-python-hacker-tools-virtualenv-fabric-pip/


Best,
Darren


-- 

Darren L. Weber, Ph.D.
Programmer/Analyst on Chimera Development Team
Resource for Biocomputing, Visualization, and Informatics
Department of Pharmaceutical Chemistry
University of California, San Francisco
Mission Bay Campus (MC 2240), Genentech Hall (Room N453)
600 16th Street, San Francisco, CA 94158-2517
dweber[at]cgl.ucsf.edu, 415-439-0619 (google voice)
http://www.cgl.ucsf.edu/chimera/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20100820/28fe4aeb/attachment.html>


More information about the Chimera-dev mailing list