Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you compile Python C/C++ extensions for different OS/versions of Python?

I have noticed that several mature Python libraries have precompiled versions for most architectures (Win32/Win-amd64/MacOS) and versions of Python. What is the standard way to cross-compile your extensions for different environments? Wine? Virtual machines? Crowd sourcing?

like image 320
golobor Avatar asked Jan 04 '12 04:01

golobor


People also ask

What are C extensions in Python?

Any code that you write using any compiled language like C, C++, or Java can be integrated or imported into another Python script. This code is considered as an "extension." A Python extension module is nothing more than a normal C library. On Unix machines, these libraries usually end in .


1 Answers

We use Virtual Machines and a Hudson server.

We have a Virtual Machine for each architecture we support (generally compiling doesn't stretch the resources allocated to them, so a VM is fine). I guess the configuration of each VM could be managed by something like Puppet or Chef to ensure it is a suitable build environment. You could of course use real machines if you have the hardware, but you'd want to avoid using machines which people are actually using (e.g. developer workstations).

We then use a multi-configuration project in Hudson to setup a build matrix. The build matrix allows us to (with a single click) build multiple python versions, on multiple architectures, but in theory you can build every and any combination you can setup in your matrix. Of course you could use Jenkins instead.

like image 198
Mark Streatfield Avatar answered Oct 21 '22 03:10

Mark Streatfield