Python 2.x and 3.x

### Introduction

To avoid having multiple formulae with endings `-py2` and `-py3`, we will handle support for different pythons (2.x vs. 3.x) in the same formula. Further brewed vs. external python will be transparently supported.

New python Requirements:

```ruby
depends_on :python => :recommended
depends_on :python3 => :optional  # so --with-python3 option will be generated
# or to declare a specific version:
depends_on PythonInstalled.new("2.6")  
```

Most formulae should just work with this little change.


### The `python` object that will support formula dev

In the Formula class there will be a `python` object available (`python2` and `python3`, too), that supports some convenience methods which do the complicated work of figuring out the information no matter which python version or brewed vs. python from OS X:

```ruby
python.site_packages # the site-packages in the Cellar for the current formulae that will later be linked globally
python.global_site_packages
python.binary # the full path to the python binary. For brewed python: HOMEBREW_PREFIX/opt/python/bin/python2
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # The usual text to set PYTHONPATH that is only shown for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.
```

Instead of using `python`, there is also `python2` and `python3` to explicitly refer to 2.x and 3.x resp..


### Executing code only for 2.x or 3.x

It is also possible to
```ruby
if python2
  # do something specific for python 2.x
end

if python3
  # do something specific for python 3.x
end

unless python
  # do something if there is no python (or python support was disabled --without-python --without-python3)
end
```

### The `python do ... end` block

And one of the most important features is the `python`-block which creates the `python.site_packages` dir and already sets the `PYTHONPATH` correctly. This block is executes **once for each python requirement**.

Formulae that use a `setup.py` to install python bindings, can do 
```ruby

depends_on :python
depends_on :python3

python do
  # sets up PYTHONPATH and site-packages.
  # The python object within this block points to the python 2.x in the first round
  # and to 3.x in the second round.
  system python, "setup.py", "install", "--prefix=#{prefix}"
end
```

### Are now all formulae automatically available for python 3.x?

No.

Adding Python 3.x support for individual formulae and testing that will take longer and I won't do this right now for all of the formulae. However, I did this for some to test things out.

### Tasks:

- [x] `depends_on :python` Requirement (python is a synonym for python2 here)
- [x] `depends_on :python3` Requirement
- [x] Write the correct sitecustomize.py also if the requirement is used.
- [x] Improve sitecustomize.py so that multiple versions (and external) are better supported.
- [x] Write the distutils.cfg if the requirement is used.
- [x] Update Python formulae to reuse sitecustomize.py
- [x] Allow formulae to use `setup.py --prefix=#{prefix}` instead of the complicated stuff as is.
- [x] `pip` will install executable scripts to `HOMEBREW_PREFIX` (solves a few issues)
- [x] Provide `python.standard_caveats`
- [x] Add Python's pkg-config during build
- [x] Use a temporary build environment to not touch stuff outside of the python block
- [x] Provide `python.global_site_packages`
- [x] Provide `python.binary` to indirect the call to python
- [x] Replace `which_python` by `python.xy`
- [x] Provide `python do` block 
- [x] Provide `python2 do` block which is only run if a python 2.x has been found and unless `--without-python`.
- [x] Provide `python.incdir` (sometimes needed for cmake based projects)
- [x] Provide `python.libdir` (sometimes needed for cmake based projects)
- [x] Provide `python.version.major` and `python.version.minor`
- [x] Provide `python.if3then3` which evaluates to "" for 2.x and to "3" for 3.x.
- [x] Provide `python.framework` (is `nil` for non-framework builds)
- [x] Provide `python.universal?`
- [x] Provide `python.pypy?`
- [x] Provide `python.brewed?`
- [x] Provide `python.from_osx?`
- [x] test :hg download strategy
- [ ] Write test_python.rb
- [ ] Do we want `brew create --python` ?
- [x] Check that the user has not `python -> python3` symlink, which is not recommended.
- [x] Update audit to tell people to use the blocks and requirements

Formulae in homebrew core to update accordingly (list created via grep for python):
- [x] bazaar
- [x] beecrypt
- [x] boost
- [x] boost149
- [x] bulk_extractor
- [x] bup
- [x] cantera
- [x] cmu-sphinxbase
- [x] collectd
- [x] cracklib
- [x] cvs2svn
- [x] denyhosts
- [x] diffuse
- [x] disco
- [x] discodex
- [x] distcc
- [x] duplicity
- [x] enchant
- [x] fail2ban
- [x] fontforge
- [x] fsh
- [x] gdal
- [x] git-cola
- [x] git
- [x] glade
- [x] gnome-doc-utils
- [x] google-app-engine
- [x] gpsd
- [x] grass
- [x] grc
- [x] gtk-doc
- [x] io
- [x] ldns
- [x] ledger
- [x] libcaca
- [x] libdnet
- [x] liblunar
- [x] libming
- [x] libplist
- [x] libpst
- [x] librets
- [x] libstfl
- [x] libxml2
- [x] lilypond
- [x] little-cms
- [x] llvm
- [x] lorem
- [x] macvim
- [x] mapnik
- [x] mapserver
- [x] mercurial
- [x] node
- [x] omni
- [x] open-babel
- [x] opencolorio
- [x] orfeo
- [x] oscats
- [x] owfs
- [x] pil
- [x] portmidi
- [x] postgres-xc
- [x] postgresql
- [x] py2cairo
- [x] pyexiv2
- [x] pygtk
- [x] pygtkglext
- [x] pygtksourceview
- [x] pyqt
- [x] pyqwt
- [x] pyside-tools
- [x] pyside
- [x] python
- [x] python3
- [x] qscintilla2
- [x] rabbitmq-c
- [x] rabbitmq
- [x] rdiff-backup
- [x] rubber
- [x] scons
- [x] shiboken
- [x] shocco
- [x] sickbeard
- [x] sip
- [x] subversion
- [x] swatchbooker
- [x] thrift
- [x] treeline
- [x] uwsgi
- [x] vim
- [x] vte
- [x] weechat
- [x] wireshark
- [x] wxmac
- [x] xapian
- [x] xchat
- [x] yasm
- [x] yle-dl
- [x] zbar
- [x] zookeeper