Copyright (C) 2000-2012 |
GNU Info (python2.1-dist.info)Describing extension modulesDescribing extension modules ============================ Just as writing Python extension modules is a bit more complicated than writing pure Python modules, describing them to the Distutils is a bit more complicated. Unlike pure modules, it's not enough just to list modules or packages and expect the Distutils to go out and find the right files; you have to specify the extension name, source file(s), and any compile/link requirements (include directories, libraries to link with, etc.). All of this is done through another keyword argument to `setup()', the `extensions' option. `extensions' is just a list of `Extension' instances, each of which describes a single extension module. Suppose your distribution includes a single extension, called `foo' and implemented by `foo.c'. If no additional instructions to the compiler/linker are needed, describing this extension is quite simple: Extension("foo", ["foo.c"]) The `Extension' class can be imported from `distutils.core', along with `setup()'. Thus, the setup script for a module distribution that contains only this one extension and nothing else might be: from distutils.core import setup, Extension setup(name="foo", version="1.0", ext_modules=[Extension("foo", ["foo.c"])]) The `Extension' class (actually, the underlying extension-building machinery implemented by the `build_ext' command) supports a great deal of flexibility in describing Python extensions, which is explained in the following sections.
automatically generated by info2www version 1.2.2.9 |