title: Finding python site-packages directory with CMake
body: <p>I use CMake to build my application. How can I find where the python site-packages directory is located?  I need the path in order to compile an extension to python.</p>
  
  <p>CMake has to be able to find the path on all three major OS as I plan to deploy my application on Linux, Mac and Windows.</p>
  
  <p>I tried using</p>
  
  <pre><code>include(FindPythonLibs)
  find_path( PYTHON_SITE_PACKAGES site-packages ${PYTHON_INCLUDE_PATH}/.. )
  </code></pre>
  
  <p>however that does not work. </p>
  
  <p>I can also obtain the path by running </p>
  
  <pre><code>python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
  </code></pre>
  
  <p>on the shell, but how would I invoke that from CMake ?</p>
  
  <p>SOLUTION:</p>
  
  <p>Thanks, Alex.
  So the command that gives me the site-package dir is:</p>
  
  <pre><code>execute_process ( COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
  </code></pre>
  
  <p>The OUTPUT_STRIP_TRAILING_WHITESPACE command is needed to remove the trailing new line.</p>