Building a python extension on Windows

Chris Angelico rosuav at gmail.com
Tue Oct 27 14:33:25 EDT 2015


On Tue, Oct 27, 2015 at 3:17 PM, Ken Brooks <kb at sparklight.com> wrote:
> I checked out a copy of svn.python.org/projects/stackless/trunk because it
> seems to have a good sample project (PC/example_nt) for building a Python
> extension on Windows. That directory has a Microsoft Visual C++ solution
> file which can be updated to my Visual C++ version (8, of 2005).

Building Python extensions on Windows depends heavily on the exact
versions of the MS C compiler and CPython you use. Specifically, to
use your extension with the standard python.org downloadable Python,
you *must* use the same compiler that was used to build it. You
mentioned that it went looking for python27.lib, which implies that
you're using Python 2.7. That uses (and thus requires) a version of
the MS compiler that is no longer supported in the normal way, but you
can get it here:

http://www.microsoft.com/en-au/download/details.aspx?id=44266

Unless you have a good reason for using 2.7, I would strongly
recommend grabbing Python 3.5 instead. Starting with 3.5, the Windows
builds of CPython are using a new "universal library" that will allow
future compilers to be much more compatible with current versions, so
you'll have an easier time of it down the track. Check out Steve
Dower's blog on the subject:

http://stevedower.id.au/blog/building-for-python-3-5-part-two/

If that doesn't help, you might do well to join the python-win32
mailing list, where you'll find a lot of people who know about the
specific details and difficulties of building Windows extensions.

ChrisA



More information about the Python-list mailing list