Tip: easy_install / pip
With all of the exciting updates to Mercurial recently, I've been on a rampage, updating various boxes everywhere I go. I'm in the habit of using easy_install and/or pip to install most of my Python-related packages. It's pretty easy to install packages that are in well-known locations (like PyPI or on Google Code, for example). It's also pretty easy to update packages using either utility. Both take a -U parameter, which, to my knowledge, tells it to actually check for updates and install the latest version.
That's all fine and dandy, but what happens when you want to install an "unofficial" version of some package? I mean, what if your favorite project all of the sudden includes some feature that you will die unless you can have access to it and the next official version is weeks or months in the future? There are typically a few avenues you can take to satisfy your needs, but I wanted to bring up something that I think not many people are aware of: easy_install and pip can both understand URLs to installable Python packages.
What do I mean by that, you ask? Well, when you get down to the basics of what both utilities do, they just take care of downloading some Python package and installing it with the setup.py file contained therein. In many cases, these utilities will search various package repositories, such as PyPI, to download whatever package you specify. If the package is found, it will be downloaded and extracted.
In most cases, you can do all of that yourself:
$ wget http://pypi.python.org/someproject/somepackage.tar.gz $ tar zxf somepackage.tar.gz $ cd somepackage $ python setup.py install
Both easy_install and pip obviously do a lot of other magic, but that is perhaps the most basic way to understand what they do. To answer that last question, you can help your utility of choice out by specifying the exact URL to the specific package you want it to install for you:
$ easy_install http://pypi.python.org/someproject/somepackage.tar.gz $ pip install http://pypi.python.org/someproject/somepackage.tar.gz
For me, this feature comes in very handy with projects that are hosted on BitBucket, for example, because you can always get any revision of the project in a tidy .tar.gz file. So when I'm updating Mercurial installations, I can do this to get the latest stable revision:
$ easy_install http://selenic.com/repo/hg-stable/archive/tip.tar.gz
It's pretty slick. Here's a full example:
[user@web ~]$ hg version Mercurial Distributed SCM (version 1.2.1) Copyright (C) 2005-2009 Matt Mackall <firstname.lastname@example.org> and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [user@web ~]$ easy_install http://selenic.com/repo/hg-stable/archive/tip.tar.gz Downloading http://selenic.com/repo/hg-stable/archive/tip.tar.gz Processing tip.tar.gz Running Mercurial-stable-branch--8bce1e0d2801/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Gnk2c9/Mercurial-stable-branch--8bce1e0d2801/egg-dist-tmp--2VAce zip_safe flag not set; analyzing archive contents... mercurial.help: module references __file__ mercurial.templater: module references __file__ mercurial.extensions: module references __file__ mercurial.i18n: module references __file__ mercurial.lsprof: module references __file__ Removing mercurial unknown from easy-install.pth file Adding mercurial 1.4.1-4-8bce1e0d2801 to easy-install.pth file Installing hg script to /home/user/bin Installed /home/user/lib/python2.5/mercurial-1.4.1_4_8bce1e0d2801-py2.5-linux-i686.egg Processing dependencies for mercurial==1.4.1-4-8bce1e0d2801 Finished processing dependencies for mercurial==1.4.1-4-8bce1e0d2801 [user@web ~]$ hg version Mercurial Distributed SCM (version 1.4.1+4-8bce1e0d2801) Copyright (C) 2005-2009 Matt Mackall <email@example.com> and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Notice the version change from 1.2.1 to 1.4.1+4-8bce1e0d2801. w00t.
Edit: devov pointed out that pip is capable of installing packages directly from its repository. I've never used this functionality, but I'm interested in trying it out sometime! Thanks devov!