title: Homebrew: PATH env var is modified before installation of Formulae (mercurial will use system python instead of homebrew python)
body: <p>Trying to use Homebrew on Mac OS X 10.9 to install mercurial and make sure it's using homebrew python version.</p>
  
  <p>I've updated <code>/etc/paths</code> to list <code>/usr/local/bin</code> before <code>/usr/bin</code>.</p>
  
  <p>Installed python 2.7.9 using <code>brew install python</code>, the python executable is located at <code>/usr/local/bin/python</code> which is a symlink to <code>/usr/local/Cellar/python/2.7.9/bin/python</code>.<br>
  When I type <code>which python</code> or <code>python -V</code> I'm getting the homebrew python version.</p>
  
  <p>Later, when I run <code>brew install mercurial</code> the installed file <code>/usr/local/bin/hg</code> shebang (<code>#!</code>) points to the system python <code>/usr/bin/python</code>.<br>
  This is happening because mercurial python package installer (distutils) is using the PATH variable to hardcode the path to python in shebang instead of <code>#!/usr/bin/env python</code>.</p>
  
  <p>When I check my PATH environment variable I see <code>/usr/local/bin</code> before <code>/usr/bin</code>, but if I try to install a brew package interactively: <code>brew install -i mercurial</code> I get a shell with a different PATH variable without <code>/usr/local/bin</code> at all.</p>
  
  <p>How can I install mercurial to make sure it will use the homebrew version of python ?
  I prefer a way that would survive mercurial package upgrades as well.</p>