| | 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 | {{{ |
| | 9 | source ~/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 |
| | 14 | mkdir -p ~/Downloads/deb-src |
| | 15 | cd ~/Downloads/deb-src |
| | 16 | apt-get source --download-only python-sip |
| | 17 | dpkg-source -x sip4-qt3_4.10.1-0ubuntu1.dsc |
| | 18 | cd sip4-qt3-4.10.1/ |
| | 19 | python configure.py --help |
| | 20 | python configure.py --debug --platform=linux-g++-64 |
| | 21 | make |
| | 22 | make install |
| | 23 | deactivate |
| | 24 | }}} |
| | 25 | |
| | 26 | {{{ |
| | 27 | source ~/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 |
| | 33 | mkdir -p ~/Downloads/deb-src |
| | 34 | cd ~/Downloads/deb-src |
| | 35 | apt-get source --download-only python-qt4-dev |
| | 36 | dpkg-source -x python-qt4_4.7.2-0ubuntu1.dsc |
| | 37 | cd 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 |
| | 41 | python configure.py --debug --trace --qmake=/usr/bin/qmake-qt4 --no-qsci-api --no-designer-plugin |
| | 42 | make |
| | 43 | make install |
| | 44 | deactivate |
| | 45 | }}} |
| | 46 | |
| | 47 | {{{ |
| | 48 | source ~/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 |
| | 54 | mkdir -p ~/Downloads/deb-src |
| | 55 | cd ~/Downloads/deb-src |
| | 56 | apt-get source --download-only libqscintilla2-dev |
| | 57 | dpkg-source -x qscintilla2_2.4.3-0ubuntu1.dsc |
| | 58 | cd qscintilla2-2.4.3/Python |
| | 59 | python configure.py --debug --trace |
| | 60 | make |
| | 61 | make 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. |
| | 65 | deactivate |
| | 66 | }}} |
| | 67 | |
| | 68 | Let'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 | {{{ |
| | 71 | source ~/src/chimera-virtualenv/bin/activate |
| | 72 | pip install pylint |
| | 73 | pip install pyflakes |
| | 74 | pip install rope |
| | 75 | deactivate |
| | 76 | }}} |
| | 77 | |
| | 78 | That should satisfy most of the [http://packages.python.org/spyder/installation.html#dependencies spyder dependencies]. Now try to install spyder using pip. |
| | 79 | |
| | 80 | {{{ |
| | 81 | source ~/src/chimera-virtualenv/bin/activate |
| | 82 | pip install spyder |
| | 83 | deactivate |
| | 84 | }}} |
| | 85 | |
| | 86 | OK, if that works, then try to setup the environment and run spyder. |
| | 87 | |
| | 88 | {{{ |
| | 89 | source ~/src/chimera-virtualenv/bin/activate |
| | 90 | #export CHIMERA=$(cd $HOME/src/Chimera64-daily && pwd -P) |
| | 91 | export 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). |
| | 96 | export LD_LIBRARY_PATH=$CHIMERA/lib |
| | 97 | #export LD_PRELOAD=libotf.so |
| | 98 | |
| | 99 | export TCL_LIBRARY="$CHIMERA/lib/tcl8.6" |
| | 100 | export TCLLIBPATH="{$CHIMERA/lib}" |
| | 101 | unset TK_LIBRARY |
| | 102 | unset TIX_LIBRARY |
| | 103 | export PATH=$PATH:$CHIMERA/bin |
| | 104 | unset PYTHONHOME |
| | 105 | unset PYTHONPATH |
| | 106 | spyder |
| | 107 | }}} |
| | 108 | |
| | 109 | |
| | 110 | If that fails (as it did for me), try using sudo privileges (this worked for me): |
| | 111 | |
| | 112 | {{{ |
| | 113 | sudo -i |
| | 114 | source /home/dweber/src/chimera-virtualenv/bin/activate |
| | 115 | export CHIMERA=$(cd /home/dweber/src/Chimera64-build && pwd -P) |
| | 116 | #export CHIMERA=/opt/UCSF/Chimera64-2010-08-24 |
| | 117 | export PATH=$PATH:$CHIMERA/bin/ |
| | 118 | export LD_LIBRARY_PATH=$CHIMERA/lib |
| | 119 | export LD_PRELOAD=libotf.so |
| | 120 | export TCL_LIBRARY="$CHIMERA/lib/tcl8.6" |
| | 121 | export TCLLIBPATH="{$CHIMERA/lib}" |
| | 122 | unset TK_LIBRARY |
| | 123 | unset TIX_LIBRARY |
| | 124 | unset PYTHONHOME |
| | 125 | unset PYTHONPATH |
| | 126 | spyder |
| | 127 | }}} |
| | 128 | |
| | 129 | |
| | 130 | ==== TODO: launching spyder within Chimera ==== |
| | 131 | |
| | 132 | Eric 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 | |
| | 140 | Then 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 | |
| | 151 | This 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 | |
| | 153 | A 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. |