CeleriD

CeleriD is an extension to Python's distutils, originally written by David Rushby. It extends distutils to know about the DMD compiler (on Windows) and the GDC compiler (on Linux). The following trivial example setup.py file is enough to compile a simple one-file extension module:

# Import from celerid instead of distutils
from celerid.support import setup, Extension

project = 'testdll'

setup(
    name=project,
    ext_modules=[
        Extension(project, [project + '.d'])
    ],
)

Compiling the module is a simple matter of running this:

>python setup.py build

The Python module celerid.support, when imported, hot-patches distutils to know about the D compiler. It also provides the following:

setup
This is simply an alias of distutils.core.setup, included here so you only have to import celerid.support in your setup.py module.
Extension
This is a subclass of distutils.core.Extension. It supports all of the arguments of the base class, with the exception of define_macros and undef_macros. D does not have a preprocessor, so an exception will be raised if you attempt to use either of these options. This class also supports these additional arguments beyond the base class:
version_flags
This should be a list of strings, which will be passed to the D compiler as version flags.
debug_flags
Similar to version_flags, the strings in this list will be passed to D as debug flags.
raw_only
This flag defaults to False. When True, it supresses the compilation and linkage of Pyd, StackThreads, and meta. This is useful if you only want to write a raw Python/C extension without the overhead of Pyd and its auxiliary packages. This is equivalent to specifying False to the next four flags.
with_pyd
This flag defaults to True. When False, it supresses the compilation and linkage of Pyd. This is useful if you want to write a raw Python/C extension and don't want the overhead of compiling Pyd.
with_st
This flag defaults to True. When False, it supresses the compilation and linkage of StackThreads. Pyd uses StackThreads for its iteration wrapping support. By setting this to False, opApply wrapping, Iter, and AltIter will be unavailable. If with_pyd and this are True, then the Pyd_with_StackThreads version flag will be defined (which is used internally by Pyd). Important note: StackThreads does not currently work with GDC! CeleriD will always set this flag to False when using GDC! This means that opApply wrapping is not available on Linux at this time.
with_meta
This flag defaults to True. When False, it supresses the compilation and linkage of meta (Pyd's metaprogramming package). Because Pyd depends on meta, an exception will be raised if with_pyd is True and this is not.
with_main
This flag defaults to True. When False, it supresses the use of the "magic" PydMain function. (Instead, users must manually declare a C-style init function.) Do not use this unless you know what you are doing. If with_pyd is False, this will silently be set to False as well. PydMain can only be used if Pyd itself is in use.