Skip to content
Laeeth Isharc edited this page Mar 19, 2015 · 1 revision

Table of Contents

CeleriD

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

Compiling the module is a simple matter of running this:

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_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.
    • **build_deimos**:
This flag defaults to False. When True, build object files for the deimos headers. Ideally, this should not be necessary; however some compilers (*cough* ldc) try to link to PyObject typeinfo. If you get link errors like try setting build_deimos=True. Note this will make compilation slower.
    • **optimize**:
This flag defaults to False. When True, have d compiler produce optimized code, at the expense of safety features such as array bounds checks.
    • **d_lump**:
This flag defaults to False. When True, lump compilation of all d files into 1 command
    • **d_unittest**:
This flag defaults to False. When True, have d compiler generate unittest code.
    • **d_property**:
This flag defaults to True: have d compiler enable property checks.
    • **string_imports**:
Specify string import files to pass to d compiler. Takes a list of strings, each of which is a path to either a string import file or a directory containing desired string import files.

pydexe

Celerid provides the custom command 'pydexe' for building projects that embed python. Usage is similar to building extensions:

Howtos

How do you control the compiler used by CeleriD?

As with distutils, you can use the commandline switch:

How do you link in additional d libraries with celerid?

Apparently you can't. This will change.