Programming Google App Engine on Linux
September 4th, 2012 § Leave a Comment
On this post we are going to setup our linux environment in order to be able to code for Google App Engine. It’s really not as simple to do as in macs (which I use in the office) but it’s doable. Why bother? I wanted to be able to be “mobile” so I setup my laptop which is dual boot Windows/Gentoo Linux for the job. Why didn’t I use Windows? Well… after leaving my previous job where I was programming in .net for about 5 years I was a bit fed up with windows. Also, my laptop came with Vista (which I hate) and I didn’t want to bother installing a new Windows OS in it. Finally, I love my Gentoo/Gnome 3 setup :).
As a note, since I uses Gentoo, in many cases I have to take the long path. Before following these steps, check if your distro’s package manager has a package ready for each of these.
Install Python 2.7
This step depends on your distro, I guess since you are willing to start programming on it, you know how to use the package manager.
Setup Additional Libraries
If you want to use the Imaging API, you have to have the PIL (Python Imaging Library) installed on your system. Make sure you have enable support for all types of files you need. Again, this depends on your distro.
Installing the SDK
Now that our environment is ready, we will install the SDK. Head over to https://developers.google.com/appengine/downloads and download the package for Linux/Other Platforms. Unzip it (I suggest to /usr/lib/google_app_engine)
My IDE of choice for app engine is Aptana. Again, grab from your distro’s package manager (for Gentoo, I “cheated” and downloaded the binary files, placed them on /usr/lib/aptana-studio-3 and created a shell script in /usr/bin in order to run it)
Install Aptana Plugins
Some things are done easier if you use plugins
Git for Eclipse
With the standard git plugin that comes with Aptana I run into a few problems, so I installed this one that was suggested on the footer of GitHub. It features better github integration and a few helpful gimmicks. Check the website for more info.
Install Debug Tools
Of course, in order to test a project, you’ll use all the main browsers (Firefox, Chrome/Safari, Opera, IE), but we are going to use firefox as a debuging platform with the use of the following add-ons.
There’s no need to further discuss this… if you are into web development you know firebug.
If your project has a few web services (RESTful, SOAP or whatever), you really need a way to test them. RESTClient comes to the rescue.
Creating a Project
Start by creating a new Google App Engine Project (although you can just create a a PyDev project and run it like an app engine project). Go to File -> New Project -> PyDev -> PyDev Google App Engine Project and click Next. Name it and after clicking Next, Aptana will ask you for the path of the Google App Engine Directory. Browse to where you had unzipped the SDK (/usr/lib/google_app_engine in my case). Click Finish and you’re done.
Configuring and Running the Development Server
Click on Run -> Run Configurations, right click on PyDev Google App Run and Click on New. On the Main tab name the run configuration, I use the project’s name, select the project and on Main Module browse to dev_appserver.py on the SDK installation directory (/usr/lib/google_app_engine/dev_appserver.py in my case).
Go to the Arguments tab. This is where you’ll configure the development server. Check Google’s reference of the Arguments. My Arguments string is similar to the following:
"$(project_loc)" --port=8080 --datastore_path="$(workspace_loc)/datastore/$(project_name)" --storage_path="$(workspace_loc)/storage/$(project_name)/"
The first argument $(project_loc) is an Aptana variable that holds the project’s path. You could add something like /src if that’s the way you structure your projects.
Then –port says the development server to listen for requests on this port. I usually have many projects running at the some time and sometimes communicating with each other, so this is a must for me.
The next argument is crucial if you want the data you enter on your application to remain after you reboot. By default, the development server uses a path on a temporary directory. We can override this by setting the –datastore_path argument. As you can see I’ve set a folder named datastore on my workspace path ($(workspace_loc)) on which I keep the datastores for each project using it’s name ($(project_name))
Leave a Reply