[Distutils] conditionally compiling extensions

Christopher Armstrong radix at twistedmatrix.com
Mon Mar 5 21:13:49 CET 2007

Twisted has a few extension modules that it only wants to build if
certain things are available on the platform - like epoll support if
the epoll.h header file is available, for example.

We can call a function to run some code to decide which extensions to
build, but in certain cases having access to the compiler object in
distutils would be preferable -- to test certain things about the
platform. Currently we have some fairly heinous hacks to get our code
to run *after* that compiler object is available (i.e., after it's
constructed in build_ext.run), but these hacks are becoming
problematic especially for easy_install support.

Before showing what these hacks are (if you really care, you can check
the various setup.py files in the Twisted repository), I'd like to ask
if there is any other best-practice knowledge in the community for
conditionally building extensions based on knowledge only available by
using a compiler.

Christopher Armstrong
International Man of Twistery

More information about the Distutils-SIG mailing list