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 importcelerid.supportin 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 ofdefine_macrosandundef_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. WhenTrue, 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 specifyingFalseto the next four flags. with_pyd- This flag defaults to
True. WhenFalse, 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. WhenFalse, it supresses the compilation and linkage of StackThreads. Pyd uses StackThreads for its iteration wrapping support. By setting this toFalse, opApply wrapping,Iter, andAltIterwill be unavailable. Ifwith_pydand this areTrue, then thePyd_with_StackThreadsversion 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 toFalsewhen using GDC! This means that opApply wrapping is not available on Linux at this time. with_meta- This flag defaults to
True. WhenFalse, it supresses the compilation and linkage ofmeta(Pyd's metaprogramming package). Because Pyd depends on meta, an exception will be raised ifwith_pydisTrueand this is not. with_main- This flag defaults to
True. WhenFalse, it supresses the use of the "magic"PydMainfunction. (Instead, users must manually declare a C-styleinitfunction.) Do not use this unless you know what you are doing. Ifwith_pydisFalse, this will silently be set toFalseas well.PydMaincan only be used if Pyd itself is in use.