title: Extending a C++ application with python
body: <p>I have a legacy (but still internally maintained) application written in C++ which handles some hardware, interacts with databases, receives commands via serial line or socket... in short it does a non-trivial amount of work.</p>
  
  <p>This application runs under Linux (ARM/Buildroot).</p>
  
  <p>Now the need is to revamp the control interface adding a RESTful API.</p>
  
  <p>I am exploring the possibility to do so via a Python extension.</p>
  
  <p>Note I am a C++/java programmer and I'm not really proficient in Python, but I know the basics.</p>
  
  <p>General idea would be:</p>
  
  <ul>
  <li>Start a Python interpreter as a thread in the C++ application.</li>
  <li>Use Flask/jinja2 (or just plain Bottle) to handle incoming RESTful requests.</li>
  <li>Expose a few (perhaps just one) C++ class to Python.</li>
  <li>Call from Python the appropriate C++ methods to perform the required actions.</li>
  </ul>
  
  <p>I studied the official documentation (mainly pertaining plain C) and several alternatives, including:</p>
  
  <ul>
  <li>Boost.Python (possibly too heavy for our limited hardware)</li>
  <li>pybind11 (seems concerned only in extending Python, not embedding it).</li>
  <li><a href="http://www.codeproject.com/Articles/11805/Embedding-Python-in-C-C-Part-I" rel="nofollow">http://www.codeproject.com/Articles/11805/Embedding-Python-in-C-C-Part-I</a> (deals only with embedding, without giving Python access to C++ classes).</li>
  </ul>
  
  <p>Question are:</p>
  
  <ul>
  <li>does this make any sense?</li>
  <li>what is the least intrusive way (if any) to achieve this?</li>
  <li>which lib/framework is advised to use?</li>
  <li>is there some tutorial project along these lines?</li>
  </ul>
  
  <p>I know the question is quite broad, but I hope to narrow it as soon as the first comments will point me in the right direction.</p>