(A Creative Blog Name Here)

Code, math, and other things I find useful

Python build targets

While writing the code for my last post on Cython I encountered something strange regarding distutils. The code linked to the GSL library which on my machine (running OSX) is a unversal library containing both 32- and 64-bit versions. When I run

$ python setup.py build_ext --inplace

distutils attempts to build 32- and 64-bit versions of the python extensions. Since I'm using a 64-bit version of Python I get a link error due to using the wrong architecture when the 32-bit version is built.

The simplest workaround I have found is as follows

$ export ARCHFLAGS="-arch x86_64"
$ python setup.py build_ext --inplace

This causes only the 64-bit version of the extension to be built. I'm sure there is a way to make distutils only build 64-bit versions by default, but I haven't found it yet. When I do I will update the post.