Please note that these Trac pages are no longer being updated. Wiki contents/documentation have moved to GitHub.

Developing With Eclipse

This is a guide for Seattle developers to get setup using Eclipse + PyDev. This is not officially recommended (there is no official recommendation), but rather is being provided by jsamuel for those who'd like to use Eclipse with python syntax highlighting (including of .repy files) as well as for the static analysis error detection that PyDev provides, which is better than that provided by pylint and is more useful because you see the errors and warnings marked directly in your code. With PyDev setup properly, you can also not worry about accidentally using tabs and will be told if you haven't used the 2-space intent style used by our project.

This tutorial is based on Eclipse 3.5 and PyDev 1.5.3. Other versions will likely work, but some of the instructions or names of menu items may change slightly.

  • Install PyDev by following the instructions here:
    • Usually the easiest way is just to go to Help > Install New Software in Eclipse and adding as an update site, then choosing to install PyDev (you can leave the Mylyn box unchecked).

  • Restart Eclipse (you'll be prompted to do this after installing PyDev).

  • Create a new project, choose a Python project (under the PyDev heading).

  • Name the project whatever you want, uncheck the box that says "create default src folder and add it to your python path". For the rest of the steps, I'll assume you named the project "seattle".

  • It will likely require that you setup a python interpreter. That just means clicking the link they give and then, in the dialog box, click Add and put in the path to the python interpreter on your system, such as /usr/bin/python

  • Now we setup a bunch of useful preferences. In Eclipse, go to Window > Preferences.
    • Go to the section called PyDev > Editor
      • Change "Tab length" to 2
    • Go to PyDev > Editor > Code Analysis
      • In the "Unused" tab, change "Unused parameter" to "warning"
    • Go to General > Content Types
      • Expand the Content Type "Text" so you see "Python File" listed.
      • Select "Python File", then click Add and add the following (repeat for each, that is):
        • "*.repy"
        • "*.mix"
    • Go to General > File Associations
      • Click Add and add the following (repeat for each):
        • "*.repy"
        • "*.mix"
      • Now, the two you just added show up in the list. Click on each and in the "Associated Editors" box below do Add, choose PyDev Editor, and then select Default for the PyDev Editor you just added.
    • Click "OK". We're done with system-wide preferences.

  • Right-click on the "seattle" project you added earlier. That is, in the PyDev Package Explorer probably shown on the left side of Eclipse, right click on the name of the project (whatever it is, even if you didn't call it "seattle").
    • In the tab "Source Folders" (where you probably start out), click on "Add source folder" and just select the project itself, whatever you called it.
    • Click "OK"
    • Note: Down the road, you may actually want to revisit this step and choose more specific source folders. That might make using modules from other folders not show up as errors and it might save time when opening/closing eclipse as it may have less files to look at.

  • Note: We're not going to bother with using Subclipse, the SVN plugin for eclipse. The reason is that I couldn't quickly get it to play nice with ssh+svn. If we were going to use Subclipse, we probably would have started out making a Subclipse SVN project (then chosing Python project when it asks) rather than making a Python project initially. If you figure out how to get ssh+svn working, let me know. Subclipse is very nice but wasn't essential enough for me to spend much time messing with it here.
  • So, now you need to open a shell, go to your workspace's seattle directory (the one created for the project), and checkout trunk:
    svn co svn+ssh://
    If you don't have ssh access and want to use read-only svn access, you can use:
    svn co
    • That will actually get you a trunk/ directory inside of the seattle directory. That's fine for our purposes. If you want things setup differently, you can fiddle around with it as needed. For example, if you specify an additional last argument to the svn co command which is the "seattle" directory for your project, that will avoid having the extra directory level called "trunk" in there.

  • Now that you've checked out from svn, right-click on the project listed in Eclipse and select "refresh" so that it will scan the new files and directories from svn.