-{ a hewer of maps }-

Install Pip script

Introducing a pure python means to install pip and it's requirements all in one go.

Installing pip on Windows is relatively straightforward, now, but still a tad bumpy. Basically it consists of

  1. Download distribute or setuptools
  2. Install it with python distribute_setup.py
  3. Download the get-pip script
  4. Install with python get-pip.py

(Aside: curiously the distribute docs say you can use pip to install distribute!)

On Windows this means installing wget or curl in order to follow the install instructions as given, or pointing and clicking your through click-this-url >> save as >> choose a spot >> open a python shell >> ...etc.. Easy, but boring and easy to make small mistakes which means repeating all or part of the recipe.

So as part of my continuing quest to learn enough to be called a true pythonista, I wrote a small script to do it all in one go, install-pip.py. It is adapted from Fernando Macedo's answer in How to install pip on windows?. The seminal idea is it use urllib to do the download, which is included in Python's standard library -- isn't it just great to have batteries included? (though it would begs the question of why there isn't a python package installer battery included...)

The script does a bit more, but here's the essential idea (the blog renderer is messing up the indentation, sorry):

sources = [

for src in sources:
    f = urlopen(src).read()
    try: exec(f)
    except: pass

Passing on an exception instead of dealing with it isn't a great idea, maybe even a stupid one, but without it only the first file is executed. Comments, fixes, and enhancements are all welcome. :)

See https://gist.github.com/maphew/5393935

Deploy website with rsync » « Plus 1 for static site generators!