Wednesday, April 29, 2009

Google App Engine & Eclipse

I am going to show you how to run your Google App (Python) in eclipse without any special plugins!

All you need to do is ensure that you have downloaded and installed both the Google App Engine and Python.

The trick to getting Google apps to run within eclipse is to run your app as an 'External Tool'.

From the Eclipse file menu, click on
Run -> External Tools -> External Tools Configuration ...

In the resulting window, choose to create a new program:



Give it a name (I called it 'App Engine') in the Name field. In the Location field, enter the exact path to your Python executable. For the Working Directory, enter the exact path to the Google App Engine.

The Arguments field is the most interesting one! Here we enter:

dev_appserver.py -d ${resource_loc}

The dev_appserver.py is the Python script that Google tells you to run when you want to test your app.

The -d just tells the App Engine to output debug statements. Feel free to use any command line arguments that the App Engine allows!

Finally, the ${resource_loc} tells Eclipse to use the full path of any item currently selected in the Navigator.


The final thing to do is to click on the Common tab and to Select "Display in favorites menu". This will provide you with a shortcut so that running your Google App requires the least amount of clicks!


Set up is complete!

Now choose the root folder of your Google App in Eclipse and click on 'App Engine' (or the name that you named your External Tool).



As you can see, the App Engine is running!


Some Notes:
  • If the App engine looks like it has hung (froze), click in the Eclipse console and hit the return key on your keyboard. What may have happened is that the App Engine has prompted you to check for updates and Eclipse didn't show you the message.

  • If you get an Eclipse error, "Problem Occurred", make sure that the root folder for your app is selected in Eclipse (i.e. click on it!).
If you have any other things to add, please post your comments!

2 comments:

Benjamin Good said...

Are there any debugging tools that you could use to step through python code execution in the app eninge context? i.e. like you can when debugging servlets in eclipse running a tomcat app. that would be handy..

Ed said...

I just came across this linkThey basically run the app engine (in debug mode) using pydev. My method allows you to run any google app ...

I wonder if there is a Python equivalent to this JAVA technique:

-Xdebug -Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=8000

Then in eclipse, create a 'Remote JAVA Application' debug configuration ...

Eclipse has a remote application config for Perl, JS and JAVA, but not for python ... Any ideas?