Sunday, June 19, 2011

Getting Started with Google App Engine, Python 2.5 and PyDev on OS X 10.6

Last week my shiny new Apple iMac 27 inch arrived and I thought I would share my steps in getting my Google App Engine (Python) environment set up. I have previously written about setting up Ubuntu 10.10 for the same purpose and that post remains one of the most popular on this blog.

To set up our Google App Engine environment we will need the correct version of Python, the Google App Engine SDK and a Python/GAE friendly IDE.


Installing Python 2.5

Firstly comes Python itself. Despite rumours of eventually upgrading the Python version supported on Google App Engine to 2.7, Google App Engine for Python still only supports Python 2.5. Mac OS X 10.6 ships with a distribution of Python 2.6. For hassle-free Google App Engine development it is always best to stick with the supported version.

Finding a packaged distribution of Python 2.5 for Mac is more difficult than it was the last time I looked, but you can still find a package here at pythonmac.org. Download the package and install it by running the installer. If you open a command prompt and type python --version you should see Python 2.5 is now the default version.

What happened to the existing bundled Python distribution? (or any others, if installed?) They are still present - the Python executable found by the shell is the one under /Library/Frameworks/Python.framework/Versions/Current, where Current is a symbolic link to a specific version's folder. Remember this if you ever need the shell to find a different version.

Getting the Google App Engine SDK

The Google App Engine SDK is easy to find, but the Google App Engine SDK download page is a touch misleading. In the download the links for the SDK, the link offered for Mac OS X is for the Google App Engine launcher. Contrary to my original assessment this download does in fact contain the SDK. When you finish downloading the package, open it and drag the launcher file to your applications folder. When you first launch it, the program will offer to create the necessary symbolic links in your /usr/local/bin folder.

If you would like more control over how and where the SDK is installed, you can grab the Linux/Other Platforms archive instead.

I never use the graphical launcher itself; I tend to start and upload my local App Engine programs via my IDE or an Ant build script (which is probably worth a post).

Setting up an IDE

I've previously posted about PyDev for Eclipse being my Python IDE of choice for Google App Engine and this has not changed. Fortunately getting it set up is now easier - PyDev is now a bundled component of Aptana Studio 3. Aptana Studio is built on the open source Eclipse IDE, and can either be installed as a standalone application, with all the extensibility of Eclipse, or added as a plugin to an existing Eclipse installation. Download the standalone version or find the details of required update site for a plugin installation here. The nice thing about Aptana for Google App Engine development is the inclusion of support for general web technologies and specific support for Django Templates.

You can also optionally install the Google Plugin for Eclipse. The vast bulk of this plugin is dedicated to assisting Google Web Toolkit development with Java, however, and out of the box Aptana seem to have included some or all of the limited Python/Google App Engine features in their studio,  such as a way to launch the development server and a project wizard for setting up a Google App Engine project. ( To install the plugin, visit the installation page. Note that if you installed Aptana Studio as a standalone install you might need to satisfy some other Eclipse dependencies not included in the Aptana Eclipse distribution. I'm skipping the installation of the plugin at the moment.)

Within Aptana (or Eclipse), open the Preferences and add the Python 2.5 interpreter (Aptana -> Preferences -> PyDev -> Interpreter - Python). Click New and enter a name (eg. 'Python 2.5') and the path to Python 2.5. This will be the specific 2.5 path under /Library/Frameworks/Python.framework/versions/2.5/bin. Aptana/Eclipse will successfully find a range of folders to add to the PythonPath for that interpreter.

Starting a New Google App Engine Project

As mentioned, Aptana Studio now ships with a Google App Engine project wizard. This is helpful but not necessary - the most critical work to be done in making a Python project a Google App Engine project is to correctly add the SDK libraries to the Python Path recognised by the IDE. Doing this manually is described here.  To use the project wizard instead, select File -> New -> PyDev -> Google App Engine project to create a new project. Make sure to change the Grammar and the Python Interpreter both to Python version 2.5.

You will be then be asked to locate the Google App Engine SDK files. If you installed the launcher application, the SDK files are actually within the installed .app file (folder?), which might make finding these files in Finder difficult. These easiest way to track down this path is through the terminal. Find where the dev_appserver.py symbolic link is (via which dev_appserver.py) and then inspect where it is pointing (ls -l usr/local/bin/dev_appserver.py). Grab this path from the terminal and paste it into the Aptana/Eclipse prompt.

You will then be prompted to confirm the folders to add to the Python path, with your only decision about which version of Django templates you will be using.

The new project wizard will close, and your new Google App Engine project will be ready.

2 comments:

  1. Jeg købte et par Balenciaga sko til min kæreste på denne online butik. billige Balenciaga skoKvaliteten er meget god, stilen på sportssko er meget ligesom,billige Balenciaga sportssko damer det er værd at købe, værdi for pengene

    ReplyDelete
  2. InPixio Photo Studio 10 Crack is a photo editing software. Professional photos are created that can be shared on social media or sent to family and friends as postcards.
    PowerISO Crack
    Kaspersky Antivirus Crack Key Activation Code
    Razer Surround Pro Crack

    ReplyDelete