Changes between Version 40 and Version 41 of VirtualEnv


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

--

Legend:

Unmodified
Added
Removed
Modified
  • VirtualEnv

    v40 v41  
    22== Installing Chimera and a Python Virtual Environment for Chimera Development ==
    33
    4 This page contains an example of a user installation of Chimera and additional configuration options to create a virtual python environment for development with Chimera.  The Chimera distribution currently ships with a custom build of python2.7 (as of Aug, 2010).  This custom python installation may not be compatible with any other installations of python on the system (including any site-packages in other python installations).  The following examples provide a tidy way to access and add new packages in a virtual environment derived from the Chimera python installation.  Also, see additional tips on development with [wiki:ChimeraEclipse eclipse for Chimera] and ChimeraSpyder.
     4This page contains an example of a user installation of Chimera and additional configuration options to create a virtual python environment for development with Chimera.  The Chimera distribution currently ships with a custom build of python2.7 (as of Aug, 2010).  This custom python installation may not be compatible with any other installations of python on the system (including any site-packages in other python installations).  The following examples provide a tidy way to access and add new packages in a virtual environment derived from the Chimera python installation.  Also, see additional tips on Chimera development with [wiki:ChimeraEclipse eclipse-PyDev] and [wiki:ChimeraSpyder spyder].
    55
    66=== Installing Chimera ===
     
    255255}}}
    256256
    257 
    258 === Developing Chimera with spyder (a python IDE) ===
    259 
    260 [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].
    261 
    262 '''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).
    263 
    264 {{{
    265 source ~/src/chimera-virtualenv/bin/activate
    266 ## Use debian source packages instead of direct download
    267 #curl -O http://www.riverbankcomputing.co.uk/static/Downloads/sip4/sip-4.10.5.tar.gz
    268 #tar zxvf sip-4.10.5.tar.gz
    269 #cd sip-4.10.5
    270 mkdir -p ~/Downloads/deb-src
    271 cd ~/Downloads/deb-src
    272 apt-get source --download-only python-sip
    273 dpkg-source -x sip4-qt3_4.10.1-0ubuntu1.dsc
    274 cd sip4-qt3-4.10.1/
    275 python configure.py --help
    276 python configure.py --debug --platform=linux-g++-64
    277 make
    278 make install
    279 deactivate
    280 }}}
    281 
    282 {{{
    283 source ~/src/chimera-virtualenv/bin/activate
    284 ## Use debian source packages instead of direct download
    285 #cd ~/Downloads
    286 #curl -O http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-x11-gpl-4.7.4.tar.gz
    287 #tar zxvf PyQt-x11-gpl-4.7.4.tar.gz
    288 #cd PyQt-x11-gpl-4.7.4
    289 mkdir -p ~/Downloads/deb-src
    290 cd ~/Downloads/deb-src
    291 apt-get source --download-only python-qt4-dev
    292 dpkg-source -x python-qt4_4.7.2-0ubuntu1.dsc
    293 cd python-qt4-4.7.2/
    294 # configure without installing designer plugin or QScintilla API, as these
    295 # should be installed already by a prior installation of Qt4 or PyQt into the
    296 # system paths
    297 python configure.py --debug --trace --qmake=/usr/bin/qmake-qt4 --no-qsci-api --no-designer-plugin
    298 make
    299 make install
    300 deactivate
    301 }}}
    302 
    303 {{{
    304 source ~/src/chimera-virtualenv/bin/activate
    305 ## Use debian source packages instead of direct download
    306 #cd ~/Downloads
    307 #curl -O http://212.219.56.133/sites/www.ibiblio.org/gentoo/distfiles/QScintilla-gpl-2.4.3.tar.gz
    308 #tar zxvf QScintilla-gpl-2.4.3.tar.gz
    309 #cd QScintilla-gpl-2.4.3/Python
    310 mkdir -p ~/Downloads/deb-src
    311 cd ~/Downloads/deb-src
    312 apt-get source --download-only libqscintilla2-dev
    313 dpkg-source -x qscintilla2_2.4.3-0ubuntu1.dsc
    314 cd qscintilla2-2.4.3/Python
    315 python configure.py --debug --trace
    316 make
    317 make install
    318 # Ignore the failure for: cp -f QScintilla2.api /usr/share/qt4/qsci/api/python/QScintilla2.api
    319 # The QScintilla2.api file was installed by an Ubuntu package (don't overwrite it).
    320 # This was the last step in the install, everything else installed OK.
    321 deactivate
    322 }}}
    323 
    324 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.
    325 
    326 {{{
    327 source ~/src/chimera-virtualenv/bin/activate
    328 pip install pylint
    329 pip install pyflakes
    330 pip install rope
    331 deactivate
    332 }}}
    333 
    334 That should satisfy most of the [http://packages.python.org/spyder/installation.html#dependencies spyder dependencies].  Now try to install spyder using pip.
    335 
    336 {{{
    337 source ~/src/chimera-virtualenv/bin/activate
    338 pip install spyder
    339 deactivate
    340 }}}
    341 
    342 OK, if that works, then try to setup the environment and run spyder.
    343 
    344 {{{
    345 source ~/src/chimera-virtualenv/bin/activate
    346 #export CHIMERA=$(cd $HOME/src/Chimera64-daily && pwd -P)
    347 export CHIMERA=$(cd $HOME/src/Chimera64-build && pwd -P)
    348 
    349 # PROBLEM: without LD_LIBRARY_PATH, Chimera python2.7 cannot load _md5 module,
    350 # but with LD_LIBRARY_PATH set the spyder will segfault (probably a
    351 # conflict with the Chimera foreign build of some library).
    352 export LD_LIBRARY_PATH=$CHIMERA/lib
    353 #export LD_PRELOAD=libotf.so
    354 
    355 export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
    356 export TCLLIBPATH="{$CHIMERA/lib}"
    357 unset TK_LIBRARY
    358 unset TIX_LIBRARY
    359 export PATH=$PATH:$CHIMERA/bin
    360 unset PYTHONHOME
    361 unset PYTHONPATH
    362 spyder
    363 }}}
    364 
    365 
    366 If that fails (as it did for me), try using sudo privileges (this worked for me):
    367 
    368 {{{
    369 sudo -i
    370 source /home/dweber/src/chimera-virtualenv/bin/activate
    371 export CHIMERA=$(cd /home/dweber/src/Chimera64-build && pwd -P)
    372 #export CHIMERA=/opt/UCSF/Chimera64-2010-08-24
    373 export PATH=$PATH:$CHIMERA/bin/
    374 export LD_LIBRARY_PATH=$CHIMERA/lib
    375 export LD_PRELOAD=libotf.so
    376 export TCL_LIBRARY="$CHIMERA/lib/tcl8.6"
    377 export TCLLIBPATH="{$CHIMERA/lib}"
    378 unset TK_LIBRARY
    379 unset TIX_LIBRARY
    380 unset PYTHONHOME
    381 unset PYTHONPATH
    382 spyder
    383 }}}
    384 
    385 
    386 ==== TODO: launching spyder within Chimera ====
    387 
    388 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:
    389 {{{
    390 >>> import sys
    391 >>> sys.path.append('/home/dweber/src/chimera-virtualenv/lib/python2.7/site-packages/')
    392 >>> from spyderlib import spyder
    393 >>> spyder.main()
    394 }}}
    395 
    396 Then within the spyder we tried:
    397 {{{
    398 >>> import sys
    399 >>> import os
    400 >>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'share'))
    401 >>> sys.path.append(os.path.join(os.getenv('CHIMERA'), 'lib'))
    402 >>> sys.path
    403 >>> import chimera
    404 >>> chimera.runCommand('open 1gcn')
    405 }}}
    406 
    407 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.
    408 
    409 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.