Changes between Initial Version and Version 1 of ChimeraSpyder


Ignore:
Timestamp:
Sep 2, 2010, 9:16:20 PM (16 years ago)
Author:
Darren Weber
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ChimeraSpyder

    v1 v1  
     1
     2== Developing Chimera with spyder (a python IDE) ==
     3
     4[http://www.youtube.com/watch?v=TRU6tQdyYqQ And now for something completely different]!  How about installing a [http://packages.python.org/spyder/ spyder].  First, we need to install some [http://packages.python.org/spyder/installation.html#dependencies spyder dependencies], including [http://www.riverbankcomputing.com/software/sip/intro sip] and [http://www.riverbankcomputing.co.uk/software/pyqt/intro PyQt].
     5
     6'''WARNING''': This example is an unstable solution that may not work on other platforms.  This example is based on an Ubuntu linux system that had packages installed for Qt4, !PyQt4, and QScintilla2, which are [http://packages.python.org/spyder/installation.html#dependencies spyder dependencies].  Your system may need these installed, along with their development headers.  Although those packages were installed on the system, they were not directly accessible to the Chimera python build.  In my case, a solution was to download and build !PyQt4 within the Chimera virtual environment.  The order of the following installs is important (they are successive dependency resolutions).
     7
     8{{{
     9source ~/src/chimera-virtualenv/bin/activate
     10## Use debian source packages instead of direct download
     11#curl -O http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.5.tar.gz
     12#tar zxvf sip-4.10.5.tar.gz
     13#cd sip-4.10.5
     14mkdir -p ~/Downloads/deb-src
     15cd ~/Downloads/deb-src
     16apt-get source --download-only python-sip
     17dpkg-source -x sip4-qt3_4.10.1-0ubuntu1.dsc
     18cd sip4-qt3-4.10.1/
     19python configure.py --help
     20python configure.py --debug --platform=linux-g++-64
     21make
     22make install
     23deactivate
     24}}}
     25
     26{{{
     27source ~/src/chimera-virtualenv/bin/activate
     28## Use debian source packages instead of direct download
     29#cd ~/Downloads
     30#curl -O http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-x11-gpl-4.7.4.tar.gz
     31#tar zxvf PyQt-x11-gpl-4.7.4.tar.gz
     32#cd PyQt-x11-gpl-4.7.4
     33mkdir -p ~/Downloads/deb-src
     34cd ~/Downloads/deb-src
     35apt-get source --download-only python-qt4-dev
     36dpkg-source -x python-qt4_4.7.2-0ubuntu1.dsc
     37cd python-qt4-4.7.2/
     38# configure without installing designer plugin or QScintilla API, as these
     39# should be installed already by a prior installation of Qt4 or PyQt into the
     40# system paths
     41python configure.py --debug --trace --qmake=/usr/bin/qmake-qt4 --no-qsci-api --no-designer-plugin
     42make
     43make install
     44deactivate
     45}}}
     46
     47{{{
     48source ~/src/chimera-virtualenv/bin/activate
     49## Use debian source packages instead of direct download
     50#cd ~/Downloads
     51#curl -O http://212.219.56.133/sites/www.ibiblio.org/gentoo/distfiles/QScintilla-gpl-2.4.3.tar.gz
     52#tar zxvf QScintilla-gpl-2.4.3.tar.gz
     53#cd QScintilla-gpl-2.4.3/Python
     54mkdir -p ~/Downloads/deb-src
     55cd ~/Downloads/deb-src
     56apt-get source --download-only libqscintilla2-dev
     57dpkg-source -x qscintilla2_2.4.3-0ubuntu1.dsc
     58cd qscintilla2-2.4.3/Python
     59python configure.py --debug --trace
     60make
     61make install
     62# Ignore the failure for: cp -f QScintilla2.api /usr/share/qt4/qsci/api/python/QScintilla2.api
     63# The QScintilla2.api file was installed by an Ubuntu package (don't overwrite it).
     64# This was the last step in the install, everything else installed OK.
     65deactivate
     66}}}
     67
     68Let's check the additional module [http://packages.python.org/spyder/installation.html#dependencies dependencies for spyder].  The Chimera python installation includes modules for {{{numpy}}} and {{{matplotlib}}}.  The install for {{{pylint}}} is easy, but {{{scipy}}} installation is not.
     69
     70{{{
     71source ~/src/chimera-virtualenv/bin/activate
     72pip install pylint
     73pip install pyflakes
     74pip install rope
     75deactivate
     76}}}
     77
     78That should satisfy most of the [http://packages.python.org/spyder/installation.html#dependencies spyder dependencies].  Now try to install spyder using pip.
     79
     80{{{
     81source ~/src/chimera-virtualenv/bin/activate
     82pip install spyder
     83deactivate
     84}}}
     85
     86OK, if that works, then try to setup the environment and run spyder.
     87
     88{{{
     89source ~/src/chimera-virtualenv/bin/activate
     90#export CHIMERA=$(cd $HOME/src/Chimera64-daily && pwd -P)
     91export CHIMERA=$(cd $HOME/src/Chimera64-build && pwd -P)
     92
     93# PROBLEM: without LD_LIBRARY_PATH, Chimera python2.7 cannot load _md5 module,
     94# but with LD_LIBRARY_PATH set the spyder will segfault (probably a
     95# conflict with the Chimera foreign build of some library).
     96export LD_LIBRARY_PATH=$CHIMERA/lib
     97#export LD_PRELOAD=libotf.so
     98
     99export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
     100export TCLLIBPATH="{$CHIMERA/lib}"
     101unset TK_LIBRARY
     102unset TIX_LIBRARY
     103export PATH=$PATH:$CHIMERA/bin
     104unset PYTHONHOME
     105unset PYTHONPATH
     106spyder
     107}}}
     108
     109
     110If that fails (as it did for me), try using sudo privileges (this worked for me):
     111
     112{{{
     113sudo -i
     114source /home/dweber/src/chimera-virtualenv/bin/activate
     115export CHIMERA=$(cd /home/dweber/src/Chimera64-build && pwd -P)
     116#export CHIMERA=/opt/UCSF/Chimera64-2010-08-24
     117export PATH=$PATH:$CHIMERA/bin/
     118export LD_LIBRARY_PATH=$CHIMERA/lib
     119export LD_PRELOAD=libotf.so
     120export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
     121export TCLLIBPATH="{$CHIMERA/lib}"
     122unset TK_LIBRARY
     123unset TIX_LIBRARY
     124unset PYTHONHOME
     125unset PYTHONPATH
     126spyder
     127}}}
     128
     129
     130==== TODO: launching spyder within Chimera ====
     131
     132Eric and I tried a few things, including launching Chimera from within spyder and also launching spyder from within Chimera-IDLE using.  For the latter option, we tried:
     133{{{
     134>>> import sys
     135>>> sys.path.append('/home/dweber/src/chimera-virtualenv/lib/python2.7/site-packages/')
     136>>> from spyderlib import spyder
     137>>> spyder.main()
     138}}}
     139
     140Then within the spyder we tried:
     141{{{
     142>>> import sys
     143>>> import os
     144>>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'share'))
     145>>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'lib'))
     146>>> sys.path
     147>>> import chimera
     148>>> chimera.runCommand('open 1gcn')
     149}}}
     150
     151This command appeared to run and provide status in the Chimera main window, but the display did not update to show the molecule.  So, we ran into issues with process communication or something.
     152
     153A possible solution may be to clone the IDLE extension from $CHIMERA/share/Idle, to replace Idle with spyder.  Looking at the Chimera-IDLE extension, we may need to hook some kind of spyder-shell into the chimera.replyobj.  The spyder does have a startup option for --light, which seems to provide a basic shell-like interface.  Of course, that may be no better than IDLE, so that could be pointless.  The goal is to get up all the IDE features of spyder.