Skip to content

Building Extensions

PythonCHB edited this page Feb 13, 2013 · 3 revisions

Building Extensions to Python

To build extensions to Python, you need a C (and maybe C++) compiler that is compatible with your Python build.

Linux

Linux is pretty straightforward -- most systems are set up to build stuff out of the box.

To make sure, you'll need gcc and assorted developer tools. There should be standard packages for installing the developer tools. try gcc --version at the command line, and make sure you get something!

Many distros have an extra package, called something like "python-dev" that you'll need to get the headers, etc required to build extensions.

Windows:

The easiest way is to use the same MS compiler as the python.org build.

With Python2.7, that's MS Visual Studio 2008.

MS distributes an "express edition" for free -- find it, install it, and you should be good to go. It looks like you can find it here:

microsoft.com/visualstudio

You want "Visual C++ 2008 Express Edition with SP1"

you need C and C++ compilers, but not the DB stuff, etc. Chances are you'll get more than you need, but so be it.

OS-X:

Apple moves fast with its upgrades, so it's a big of a trick. The latest version of XCode is free, but does not support older systems, and thus won't work (at least not easily) for the python.org python builds.

For python.org Python2.7, you need XCode 3.* (latest is 3.2.6)

If you have a pre-lion (10.6 or below) system, you may have gotten XCode with your install DVDs, on the extras disk or something like that. If so, I'd install from there, it's a big download.

for Lion (10.7 and above) -- you'll need to download it. Apple makes it a bit hard to find the older versions, but they can be found at:

developer.apple.com

you need to login with an AppleID (or create one), then select "Developer Tools", and search for Xcode -- poke around a bit, and you'll eventually find:

XCode 3.2.6 and iOS SDK

Download and install it (do it with a fast connection -- it's huge)

You should be good to go.

Clone this wiki locally