Extending Python with Visual C++ and PTVS

Last month there was a chance I gave a talk explaining how to start the PTVS(Python Tools for Visual Studio) through the MS virtual academy. The talk was live recorded and currently is being shared following URL:


It’s Korean though. Throughout the demo, except the very basic examples I also included demos showing how to build a Python extension with C++ which is integrated greatly with Visual Studio C++ compiler and the PTVS, and how to debug cross platform python modules running on Raspberry Pi.

Although the C++ python extension example I wrote was super simple and copy&pasted almost from python.org example, I uploaded mine here including C++ and python sample sources because it wasn’t easy to find as complete visual studio solution form.

GitHub repo URL: https://github.com/heejune/demo-python-PyCExtDemo1

Also if you want to start building a C++ python extension with Visual Studio and PTVS please refer to following steps:

1. Specify the include directory contains python headers.


2. Add python27.lib or appropriate version corresponds to.


3. Add libs directory into additional lib path.


4. Lastly, don’t forget enabling ‘Mixed mode debugging’ and matching python environment’s architecture version with python extension architecture (as follows)