Here’s a quick roundup on how to build Python extensions using the Microsoft Visual C++ 2005 Express Edition compiler. This is meant for people who need to build Python extension from source using the accompanying
There’s no rocket science or magic involved. Just five easy click-through steps. Well, the last one actually is a bit of manual editing, but not so much. And the best thing of all: it’s all available for free!
- Probably you will already have Python installed, but for the sake of completeness: download and install Python (get one of the Windows Installers)
- Download and install VC++ 2005 Express (pretty obvious)
- At the end of the VC++ 2005 Express installation, you will be asked to register your copy. Please, do so. It’s for free, and if you don’t do it, your copy will stop working after a week or so. If you’ve skipped registration, you can still do it from the Help menu by clicking on Register Product.
- VC++ 2005 Express is a limited edition and is not capable of building Win32 applications out of the box (it can build .NET applications though). For the most simple extensions you probably won’t need that, but sooner or later you will hit that limitation. Fortunately, you can solve that issue (for free again) by installing the Windows Platform SDK. If you follow the previous link, you will notice it actually goes a download page for the Windows Server 2003 R2 Platform SDK. That’s OK, it’s exactly what you need. Caution: if you go looking for the Windows Platform SDK via google, you probably will find a previous version. So just use that link I gave you.
- By now, you have installed on your computer everything you need to build Python extensions using Visual C++ 2005 Express Edition. All that’s is left to do is to update some settings in VC++ 2005 Express so it can find the necessary headers and libraries. Open up the Options dialog from the Tools menu. On the left, select VC++ Directories from the node Projects and Solutions. In the top-right corner, you’ll then find a dropdown box titled Show directories for. Add the following directories:
- Executable files:
- C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin
- Include files:
- C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include
- Library files:
- C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib
- Executable files:
That’s it! Enter
setup.py install and go!