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!

A couple of pre-requisites first: You need to have enabled the root user to be able to Sudo and I'm assuming you have already installed Python 2.5 (see my previous post for more information on that)

Installing SetupTools

I still prefer to install Pylint via SetupTools. SetupTools makes the easy_install command available from the shell to automatically install python eggs and sort out their dependencies. You might already have SetupTools on your system, but do you have the Python 2.5 version? I assume it is important (it does after all need to install packages into the correct site-packages folder). To install SetupTools, first download the egg file:

http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg

Open a terminal session and cd into the folder you saved it into. Type the following into the commandline:

$ sudo sh setuptools-0.6c11-py2.5.egg

This will install setup tools. When you run easy_install, make sure to use the command easy_install-2.5 to make sure you are addressing the correct Python installation on your system.

Installing PyLint 

Type the following into your terminal shell:

$ sudo easy_install-2.5 pylint

This will install PyLint and all of its dependencies. You can now run PyLint from the command line (or from an Ant Task).

Using PyLint in Aptana

Aptana (now incorporating PyDev - again see my previous post) can integrate with PyLint to give you feedback on code style as you work and make changes to your source files. To configure Aptana to do this, open Preferences -> Pydev -> PyLint, check the the Use PyLint option and locate your Pylint executable. Despite the hint to look for a file named lint.py, I've never found such a file.

Instead, find the pylint binary. If you installed PyLint as per the above the following path should be where it is at:

/Library/Frameworks/Python.framework/Versions/2.5/bin/pylint

Click OK, open a python file and make some changes. Warnings and errors from PyLint should start appearing in the Problems view (Window -> Show View -> Problems if you can't see it). You can also specify a preferences file in the preferences page for PyLint to pass in any global settings (to ignore certain style rules, for example).

There you go. PyLint is installed and ready to use from the command line, an Ant Task or in Aptana. Let me know in the comments if you can suggest a better approach, have a question or any sort of general comment.

5 comments:

  1. Thanks for sharing this great and useful information, appreciated much the effort.|federalprocessingregistry.com

    ReplyDelete
  2. Thanks for taking the time to share this informative article here. Reading your article I got numerous valuable information about python. it support companies in dubai

    ReplyDelete

  3. A handy tool to get all the information related to your traffic and network usage in perfect health.
    The network provides several ways to view traffic statistics. Also, users can accurately monitor the progress of their downloads and uploads.
    Together with you, you can identify problems in your system network.
    Download it free from here:
    https://softserialskey.com/du-meter-download-free-crack/

    ReplyDelete
  4. UnHackMe Crack is excellent malware and Trojan protection software. Regardless, you need an additional process, as most antivirus developments do not work.
    Tenorshare Ultdata Crack
    AutoCAD 2021 Crack Serial Number
    Simplify 3D Crack

    ReplyDelete