title: Alternative to python-config callable from within Python
body: <p>I want to have a Python script build a Python C extension module for whichever version of the Python interpreter with which the script is being run.</p>
  
  <p>To this purpose, I want to dynamically acquire the relevant C compiler flags – one way to accomplish this would be to grab the output of the <code>python-config</code> CLI tool, e.g. like so:</p>
  
  <pre><code>subprocess.check_output(["python-config", "--includes"])
  </code></pre>
  
  <p>Unfortunately, on systems on which several versions of Python are installed, this method may not find the right <code>python-config</code> – that is to say, the <code>python-config</code> associated with the currently-running version of Python. (Also, it is a bit ugly, methodologically.)</p>
  
  <p>Is there some way that I can acquire this information from within Python – something perhaps like Numpy’s <code>get_include</code>?</p>