title: how to make pip respect the "CC" environment variable
body: <p>I'm working in a very convoluted environment where different machines have access to different distributed file systems.</p>
  
  <ul>
  <li>Machine <code>A</code> has access to filesystem <code>X</code> and is used to install software on filesystem <code>Y</code>.</li>
  <li>Machine <code>B</code> has access to filesystem <code>Y</code>, but not <code>X</code>.</li>
  </ul>
  
  <p>I'm working on machine <code>B</code>, and I find myself using python a lot. Sometimes, I need packages that are not preinstalled, so I use <code>pip install PKGXYZ --user</code> to install them locally. This generally works nicely, but there's a catch.</p>
  
  <p>The python packages <code>distutils</code> and its monkey-patched derivative <code>setuptools</code> which are used by <code>pip</code> use the <code>distutils.sysconfig</code> functionality to get hold of compiler versions, paths, and somesuch. For this, they use the internal <code>Makefile</code> that was used to install python. While this is generally a good strategy, it fails with my concrete setup, because the paths in pythons internal <code>Makefile</code> point to filesystem <code>X</code>, which I do not have access to on my machine <code>B</code>. Hence, I find myself using the <code>--no-clean</code> option of <code>pip</code> and hacking the <code>setup.py</code> of the packages I want to install with snippets like this:</p>
  
  <pre><code>import re
  import sys
  import os
  cc = os.getenv("CC")
  if not cc:
      print("please set CC environment variable!")
      exit(0)
  from distutils.sysconfig import get_config_vars
  for k,v in get_config_vars().iteritems():
      try:
          if "fsX" in v:
              newv = re.sub(r'/fsX/[^ ]*/g[c+][c+]',cc,v)
              get_config_vars()[k] = newv
      except TypeError:
          pass
  </code></pre>
  
  <p>such that I can use the <code>CC</code> environment variable to overwrite the default settings of the compiler path from pythons <code>Makefile</code> with something that works on my machine. </p>
  
  <p>However, this is an ugly hack. There must surely be a nicer way to do this and make <code>pip</code> use some different compiler via some environment variable, config file or command line option. Or is there?</p>