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
- Download distribute or setuptools
- Install it with
- Download the get-pip script
- Install with
(Aside: curiously the distribute docs say you can use pip to install distribute!)
On Windows this means installing
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 = [ 'http://python-distribute.org/distribute_setup.py', 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py', ] 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. :)