Friday, August 28, 2009

Enthought's reStructuredText editor

Enthought has produced a wonderful tool for getting into reStructuredText: a side-by-side WYSIWYG rST editor.

Screenshot of editor session
Getting it installed, however, just about killed me. Here are the steps I finally puzzled out for Ubuntu 9.04. Miss any steps - or even change the order - and you'll get error messages that don't help even slightly.
sudo apt-get update
sudo apt-get install python-setuptools python-vtk
sudo easy_install -U numpy
sudo easy_install -U docutils sphinx TraitsBackendQt[nonets] AppTools[nonets]

[EDIT] If you're not on 9.04, or you just want to be on the safe side, it doesn't hurt to sudo apt-get install python-dev python-qt4 at the beginning of the whole process.

The other odd thing is that this lovely editor apparently has no name, and certainly no handy start script or presence in any menu. Mine got installed at /usr/local/lib/python2.6/dist-packages/AppTools-3.3.0-py2.6.egg/enthought/rst/app.py; your best bet to find yours is probably sudo updatedb; locate -r rst/app.py$

Then, set up a bash script to make it usable. I'm calling it "rsted". sudo nano /usr/local/bin/rsted and fill it with:

#!/bin/bash
python /usr/local/lib/python2.6/dist-packages/AppTools-3.3.0-py2.6.egg/enthought/rst/app.py $*

... sudo chmod +x /usr/local/bin/rsted, and live happily ever after.

(The $* in /usr/local/bin/rsted doesn't actually do anything - the editor doesn't seem to accept arguments like a filename - but I'm being hopeful for the future.)

16 comments:

John Francis Lee said...

Hi Catherine Devlin,

Thanks for the info. Here're my results... so far.

sudo apt-get update
sudo apt-get install python-setuptools python-vtk
sudo easy_install -U numpy
had to
sudo apt-get install python-dev
then
sudo apt-get install gfortran... but easy_install numpy is happy now with the non-fortran version and won't recreate numpy with the fortran routines. Apparently there is no easy_uninstall

sudo easy_install -U docutils sphinx TraitsBackendQt[nonets] AppTools[nonets]

sudo updatedb; locate -r rst/app.py$

#!/bin/bash
python /usr/local/lib/python2.6/dist-packages/AppTools-3.3.0-py2.6.egg/enthought/rst/app.py $*

sudo chmod +x /usr/local/bin/rsted

jfl@ws3:~/Downloads$ rsted
Warning: Unable to import the wx backend for pyface due to traceback: Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/TraitsGUI-3.1.0-py2.6.egg/enthought/pyface/toolkit.py", line 40, in _init_toolkit
__import__(be + 'init')
ImportError: No module named wx.init

Warning: Unable to import the qt4 backend for pyface due to traceback: Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/TraitsGUI-3.1.0-py2.6.egg/enthought/pyface/toolkit.py", line 40, in _init_toolkit
__import__(be + 'init')
File "/usr/local/lib/python2.6/dist-packages/TraitsBackendQt-3.2.0-py2.6.egg/enthought/pyface/ui/qt4/init.py", line 18, in t;modulet;
from PyQt4 import QtCore, QtGui
ImportError: No module named PyQt4

Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/AppTools-3.3.0-py2.6.egg/enthought/rst/app.py", line 28, in t;modulet;
main()
File "/usr/local/lib/python2.6/dist-packages/AppTools-3.3.0-py2.6.egg/enthought/rst/app.py", line 24, in main
app.configure_traits()
File "/usr/local/lib/python2.6/dist-packages/Traits-3.2.0-py2.6-linux-x86_64.egg/enthought/traits/has_traits.py", line 2497, in configure_traits
kind, handler, id, scrollable, args )
File "/usr/local/lib/python2.6/dist-packages/Traits-3.2.0-py2.6-linux-x86_64.egg/enthought/traits/ui/toolkit.py", line 241, in view_application
raise NotImplementedError
NotImplementedError


Looks like I need a whole raft of additional software. I'll get back to it as soon as I can.

Unknown said...

Hi, John. Are you using Ubuntu 9.04? I know that some earlier Ubuntu distros didn't come with python-dev, but 9.04 seems to have it.

The editor also needs wx -or- Qt4. It checks for wx first, and throws a warning if it's absent, but then checks for Qt4. On my machine, apt-get install python-vtk seemed to install qt4. But you can try

sudo apt-get install python-qt4

... and I think (hope) that will be your last missing dependency.

John Francis Lee said...

Yes it is 9.04. But I used the "alternate" install program so I could mirror my hard-disk, and that may not have installed whatever the graphic installation does.

Do you know of a remedy to the numby without fortran problem? An easy_uninstall? Or is it not a problem?

OK... the addition of a mere 50mb more QT4 code made it work :) But I still get the wx.init missing error, even after

sudo apt-get install python-wxgtk2.8
sudo apt-get install python-wxtools

Another sheer, mere 50mb of code.

How much code all together? 200mb? 300? more?

Rendering does not work without enabling sphinx.

And I will now have to rename all .txt files to .rst... because the program insists on it. Won't even show other files in a directory listing.

And I really ought to have higher resolution than 1152x864... the split window makes short work of that.

But it's flashy!

Don't know if it's worthwhile.

I'll have to experiment a bit. I actually was fairly comfortable working in an ordinary text editor, replaying the rst2html command in a terminal, and hitting the refresh in firefox. Will sphinx reliably produce the same output as rst2html? The bottom line is automation and rst2html is it.

Thanks for all the tips. I appreciate it, PyOraGoddess...

PyOraGeek sounds too... geeky :)

bcw said...

I had no problems installing it, but it an UnicodeDecodeError on my german files. Perhaps this application better stays under the radar until it has matured a bit :)

Dirk Loss said...

Maybe you want to try Marek Majkowski's online, multi-user reStructuredText editor:

http://cometdemo.lshift.net:8080/

Background info:
http://www.lshift.net/blog/2009/03/02/evserver-part3-simplified-etherpad-clone

Dirk

Steve said...

Great tool--thanks Catherine! I took your advice and did the "sudo apt-get install python-dev python-qt4" step just to be safe, and it worked great.

For others that may be worried about the "not able to compile Fortran on platform 'Posix'" messages--don't be. It doesn't seem to have any ill effects.

Dave Peterson said...

Hi All,

I just took a look at the trunk of AppTools, and it looks like someone has already committed a change to make future installs create an 'rsteditor' command for you.

I've also e-mail Evan Patterson with the suggestions I got out of reading this post. Namely, allow command line args to specify files to edit; and, allow opening of files with other extensions. I'm not sure if, or when, Evan might have time to make these fixes but I'm sure we'd welcome a patch to the enthought-dev mailing list.

Evan Patterson said...

The latest trunk version of the application now allows .txt files to be opened. (In hindsight, this was a rather glaring omission.)

I'll see if I can get around to having the application take command line arguments some time today.

@John Francis Lee
You mentioned that rendering does not work without enabling Sphinx. What version of docutils are you using? Do you get a traceback?

André Roberge said...

Catherine,

In case you are interested, I have developed a similar tool that will be a tad easier to install on all platforms. (I could not install the Enthought tool on my Mac laptop.) Here is a screenshot.

Feel free to email me for details.

Evan Patterson said...

The trunk version now supports commandline arguments.

Paddy3118 said...

maybe call it by the backronym: rusted.

Where rusted stands for:
Re
Un-named
Structured
Text
Editor

:-)

Jim said...

Hey Catherine,

This is great! Thanks so much for sharing it. I think I met you briefly at Penguicon, and we talked a bit about docutils and sphinx. For now, the Xfce project is going to use sphinx for their docs. This will be a helpful tool.

denis said...

I'd like to have the editor, but
"Getting it installed, however, just about killed me (a talented geek)".
So what're my choices ?

1) try Catherine's recipe, on a mac: sure to take hours: nope

2) wait for ... to put up Mac .dmgs
2a) I'd even pay $10, enthought take note

3) switch to online, no-install, realtime editors: stackoverflow, advice.mechanicalkern.com.
Those are not quite my target
and do Markdown not ReST, but ok.

Imho no-install
e.g. google will win out over install hell e.g. Enthought.

Eric said...

Hi,

why don't you just do
sudo -apt-get install python-numpy

instead of easy_install (that, by the way, doesn't work ...)

Anonymous said...

further to eric's comments, the same applies to docutils and sphinx:

sudo apt-get install python-docutils python-sphinx python-vtk python-numpy

in addition, I found I needed python-configobj

finally, Karmic (Ubuntu 9.10) has python-apptools too, which it nice and easy :) (it's dependencies are insufficient, though - still had to install those other python packages myself)/

Anonymous said...

I haven't needed to use this tool for a long time.

My /usr/local/bin/ReSTE script was like this to be able to upgrade AppTools in a more transparent way :

#!/usr/bin/env python

from enthought.rst.rest_editor_view import ReSTHTMLEditorView
app = ReSTHTMLEditorView()
app.configure_traits()


In the 3.4.0 version the whole rst folder disapears without any trace in the documentation. It seems that it have its own root now but there's no release yet : https://svn.enthought.com/enthought/browser/Rested/