Showing posts with label Aptana Studio. Show all posts
Showing posts with label Aptana Studio. Show all posts

Thursday, June 23, 2011

Installing Pylint for Python 2.5 on Mac

In a previous post I discussed how to set up Google App Engine (Python) development environment on Mac OS X 10.6. I'm liberally mining some of my own notes on setting up Google App Engine on Ubuntu 10.10.

In my previous Ubuntu environment I had a neat Ant script for building, testing and uploading my Google App Engine applications such as My Web Brain. One of tests the script performed was Python code style checks using Pylint, which I have also mentioned before in the context of Ubuntu. I've set this up again on my Mac, so I thought I thought I would post my notes here.

In this post I talk about:

  • Installing Setup Tools for Python 2.5,
  • Installing PyLint using SetupTools, and
  • Configuring Aptana/Pydev to use PyLint
Lets go!

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.

Friday, December 3, 2010

Python Code Style

Code conventions are important in software development. In Python, where whitespace (specifically indentation) can have a functional impact on your software, coding conventions are critical, especially when code needs to be shared and reused.

Python does have a widely accepted (and widely tweaked) Style Guide called PEP 8. I saw it a while ago but didn't have the time to digest and then laboriously apply it to my active codebases.

When I recently rebooted my development environment on Ubuntu and Mac OSX I noticed the PyDev IDE (now shipping with Aptana Studio)  had support for PyLint. PyLint - like other 'linting' programs - can examine your code and find non-compliances to a specific standard of code formatting. PyLint, when used as commandline tool, can provide a detailed report on your code style.

The great thing about the integration with PyDev, however, is that PyLint shows non-compliances in your currently open files and flags them as warnings and problems in your problems view. This makes deciding to implement and meet a code standard a lot less cognitively burdensome.

PyLint also highlights bad code smells - components and practices which don't smell right that might need refactoring. PyLint can be given global instructions to ignore certain issues, or specific source files can include comments to change how PyLint analyses the file. This gives some ability to customise the behaviour and ignore PyLint where pragmatic.

To enable PyLint in PyDev, first make sure PyLint is installed. Installing PyLint is as easy as installing any python program:

$sudo easy_install pylint

If you have different python versions in your environment, use the correct invocation of SetupTools for that version. I need to target Python2.5 for Google App Engine, so I use:

$sudo easy_install-2.5 pylint

Once pyLint is installed, within Eclipse (or Aptana etcetera) visit the Preferences page and specifically the PyDev > PyLint section in the hierarchy. Locate the actual PyLint script (lint.py) and enable PyLint.

PyLint is really helping me clean up my code (I admit it - I am a recovering tab-fiend).

Monday, November 8, 2010

Quick Note: Eclipse and Subclipse on Ubuntu (for Appengine)

I have previously written about configuring PyDev on top of an Eclipse/Aptana installation for Google App Engine development. Now on the Ubuntu platform instead of the windows, the process is easier these days since Pydev ships with the new Aptana Studio 3 Beta.

I thought I would write a quick note to future Ben (i.e. me) about configuring Eclipse and Subclipse on Ubuntu. Subclipse is a Subversion plugin for Eclipse (the alternative is Subversive, which I haven't tried).

Briefly my Eclipse install (for reference):

  • sudo apt-get install eclipse (if using eclipse base install)
  • Install Aptana Studio 3 beta, either standalone or as Eclipse plugin
  • Install Google plugin for Eclipse from within Eclipse (page with download sites)
  • Configure Python 2.5 interpreter within Eclipse (assuming you have already installed Python 2.5)
  • Create new Google App Engine project (under PyDev grouping)
  • Configure Python Library Paths for Eclipse
To add Subclipse:
  • sudo apt-get install subversion
  • sudo apt-get install libsvn-java
  • install subclipse within Eclipse (download sites)
Since I eventually managed to install Python 2.5 I've had a great experience installing software on Ubuntu. I've experienced some detours but none of them have been too long. Let me know if I have missed anything, or could have done something better.

Tuesday, July 14, 2009

Running App_DevServer.py from Pydev

In my earlier post about setting up a Python Development environment for Google App Engine I mentioned I was going to explore using Aptana Studio for my Python for Google App Engine editing. So far this is going well and has been very easy to set up. Even better, for the moment PyDev seems to be bundled more or less exactly as it used to be when PyDev was independent. This is good news from the perspective that PyDev documentation and tips you can find online are still very valid.

Setup instructions for virgin eclipse installs:

  1. Go to the Aptana website and download the Aptana Studio standalone (if you have an existing Eclipse installation you can add it as a plugin as well).
  2. Install Aptana Studio
  3. From the 'My Aptana' homepage within Aptana, click on the Plugins section and click on the 'Get It' link for Aptana PyDev to install python support.
  4. From there, follow Joscha Feth's setup instructions from step 3 of Installing PyDev on Eclipse. These useful instructions explain how to set the Python interpreter correctly and what step you need for each project to bring in the Google App Engine python libraries and setup a Run configuration.
When I setup my Run configuration I ran into an issue where it seemed Eclipse was ignoring my specified arguments. When I ran the project, the dev_appserver.py script rightly complained it did not have the correct arguments.

After scouting out a couple of other websites (like this one) I cottoned on to the fact that if your project location path contains spaces, you need to place the argument in quotes, like so:

"${project_loc}/src"

This all makes perfect sense (and obvious), but in my case I was worrying the problem was something more serious. The fact that Eclipse/PyDev's own command-line inspection function was freaked out by the space (and therefore ended prematurely) meant I could not see the commandline which I hope would have clued me into the problem sooner.

The problem only took a few minutes to figure out, but maybe this post will assist someone else is spending 1 or 2 minutes less. Happy learning!

Tuesday, July 7, 2009

Setting up a Python Google App Engine development environment

I am setting a development environment for working on Google App Engine projects. I have a freshly minted Windows 7 RC virtual machine cloned from a base image and made individual. Having a separate development environment on a virtual machine for working with Google App Engine (or anything similiar) makes a lot of sense. Especially since the Google App Engine SDK is tied to a specific python version.

What do you need to do to set up the development environment (at least in MS Windows)?

  1. Install Python 2.5.4 from the Python Website. I am not sure whether Google intends to support later versions but 2.5 is definitely not the latest, so be careful to install the correct version. I accept the default program folder of C:\python25, if only because I can vaguely recall issues with paths with spaces. I also install for all users.
  2. Make sure the python interpreter is in the system path. You should be able to open a command prompt window and type 'python' from anywhere on the file system and have the interpreter found. Add the main python folder (C:\python25 in my case) and the binaries folder (C:\python25\bin) to your path.
  3. Your file associations (.py --> python) should already be set by the installer.
  4. Install the App Engine SDK for Python from the App Engine Downloads page. There is nothing special to select during the install.
  5. The installer for the App Engine SDK python should have put the scripts on the system path. If you open a (new) command prompt window you should be able to verify this by typing dev_appserver.py with no arguments.
UPDATE 15th July 2009: You should also consider installing PIL as discussed in this post.

You are now ready to rock and roll.... as long you do not mind working in notepad or notepad++.
I do not have strong opinions about an IDE at this early stage, and I am interested in hearing input. Google have a Google App Engine Eclipse Plugin but this is for Java only.

Eclipse already has an excellent plugin for Python called Pydev. However Pydev was only recently acquired by Aptana. You can find some excellent notes for installing and configuring only Pydev for Google App Engine on Google's own help page, thanks to the contributions of Joscha Feth.

However I am going to explore going down a different path. Since Google App Engine (or Django or other Python web projects) still requires static assets like Javascript and CSS in addition to HTML templates, and since Aptana is the leader in these features for Eclipse, I am going to try my luck with installing Aptana studio. I will let you know how I go.

What is everyone else using?

I would also like to discover a lightweight alternative to Eclipse editing for my Netbook (Eclipse is a beast and I am not sure my space- and processor-constrained Netbook would cope). If I find I will post it here.